AVCE ICT – Unit 7 - Programming Session 16 – Database and VB
In the real world This is what VB is most used for The user is hidden from the complexities of the database There is a user friendly front end You have the full power of a programming language to manipulate data The user doesn’t need to have MS Access installed on their machine
Databound controls These are the ones that can be bound to a database DAO (the data aware objects databound control) This is used to bind to Access 97 databases ADODC (ActiveX Data Objects Data Control) This is used to bind to Access 2000 format databases
Data aware controls These can be associated with a databound control and can be used to display data items Text boxes Labels List and combo boxes Data grid MS Flexgrid plus others
Binding For the DAO data control, set the Database Name property and then the Record Source property to the table name For the ADO, use an ODBC Data Source Name (DSN) which is very simple to set up
Binding - DAO Click on the option list to select the database The Jet Engine is the standard MS engine for searching the database
Binding - DAO This is the table name but it could be a Query that you have created in Access
Binding - ADO The Connection String property specifies the database
Setting up the DSN Select 32bit ODBC data sources from within control panel
Setting up the DSN Select Add and then select the Microsoft Access Driver followed by Finish
Setting up the DSN Select the Database and then choose a suitable Data Source Name, then click OK
Design time coding Once you have created the DSN and used that to set the Connection String property of the ADODC, you can use tools such as the Data Form Wizard (on the Add Form choices) to create a form containing all of the controls needed to access data
Queries A query can be used as a DSN in its own right You can also create and run queries within VB at run time Databases are manipulated using the very high level language called Structured Query Language or SQL (sometimes pronounced Sequel)
Assignment task A database isn’t necessary for the project but You could create a database to hold user ID, number pairs The database could be queried to authenticate the user This would be a very impressive addition!
Return to Main Menu