130 likes | 888 Views
Extension to TCL (Tool Command Language) which allows access to databases ... Note that this presentation is related to MS Access 2003. It does work with MS Access 2007 ...
E N D
Slide 1:RAD to Database Connection
Glenn Campbell Campbell-g8@ulster.ac.uk
Slide 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
Slide 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
Slide 4:Initial Steps
Before you begin, do the following: Download and install TclODBC from course website 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
Slide 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.
Slide 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
Slide 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
Slide 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.
Slide 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’
Slide 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
Slide 12:Access 2007 Considerations
Note that this presentation is related to MS Access 2003 It does work with MS Access 2007 But there may be some subtle changes in the way tclODBC is used
Slide 13: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