Presentation is loading. Please wait.

Presentation is loading. Please wait.

RAD to Database Connection Glenn Campbell

Similar presentations


Presentation on theme: "RAD to Database Connection Glenn Campbell"— Presentation transcript:

1 RAD to Database Connection Glenn Campbell Campbell-g8@ulster.ac.uk

2 Learning Outcomes After this lesson you will be familiar with: TclODBC Linking RAD application to database Creating an ODBC Data Source Name (DSN) TCL commands Using SQL to query a database

3 TclODBC Extension to TCL (Tool Command Language) which allows access to databases Uses standard ODBC interface The Rapid Application Developer (RAD) can be configured to link to a database We will use MS Access for creating the database

4 Initial Steps Before you begin, do the following: 1. Download and install TclODBC from course website 2. Create a database in MS Access called name.mdb e.g. student.mdb We can now create a link between the database and the RAD application

5 Testing TclODBC Refer to Exercise 20 of Tutorial 12 for information on how to test TclODBC in the CSLUsh window. When you are satisfied that TclODBC is working, you can then create a link between your RAD application and the Database.

6 The RAD to database connection is achieved using the following steps: Step 1: Create a link between the RAD and the database Step 2: Create an ODBC Data Source Name (DSN) for your database Step 3: Create a database object to open a connection to the database Step 4: Use SQL to query the database RAD to database connection

7 Step 1: RAD – database link Download TclODBC package into the... \CSLU\Toolkit\2.0\pkg\tclodbc2.2 directory Use the following command to create a link between RAD and the database: package require tclodbc This command loads the TclODBC program which creates a link between RAD and the database This (and any other) TCL command can be inserted into the ‘On Exit’ tab of an Action Object

8 Step 2: Create an ODBC DSN Select: Start | Control Panel | Administrative Tools | Data Sources (ODBC) | Add Now enter required information. For example, in this example, enter ‘student’ as the Data Source Name (i.e. the name of the database) Remember to select ‘Microsoft Access Driver’ and browse for the database you wish to link to.

9

10 Step 3: Create database object Use the command database to create a database object, db which refers to the DSN created in Step 2 To do this use the following command: Database db name where name is the name of the database, e.g. ‘student’

11 Step 4: Query the database The database can now be queried using SQL Again, the code is entered into the Action object: For example: set getDetails [db "Select Name from StudentRecords where StudentNumber = $value"] where Name and StudentNumber are all fields in the StudentRecords table of the student database

12 Further Information Paul Mc Kevitt’s course website http://www.infm.ulst.ac.uk/~paul/com556m2/ CSLU Toolkit webpage http://cslu.cse.ogi.edu/toolkit/ Email me: Campbell-g8@ulster.ac.uk


Download ppt "RAD to Database Connection Glenn Campbell"

Similar presentations


Ads by Google