Disponible uniquement sur Etudier
  • Pages : 15 (3691 mots )
  • Téléchargement(s) : 0
  • Publié le : 27 mars 2011
Lire le document complet
Aperçu du document
[pic]Visual Basic 6 (VB6)

Haut du formulaire
Bas du formulaire
[pic][pic]RSS: Site Feed

Navigate To

• Home
• Tutorials
• Source Code Samples
• Add Your Tutorial
• VB.NET Tutorials
• Forums
• Articles
• External Links
• Advertise Here!
• Contact Us


• Beginner Guide
• Controls Guide
•Database Guide
o Introduction to SQL
o Using Data Control
o Using DAO Code
o Using RDO
o Using ADO
o ADO and ListView
o ADO stored procs
o Using Crystal Reports


• Create content

User login

Haut du formulaire
Username: * [pic]
Password: * [pic]
• Create new account
• Request new password
Bas du formulaire
Home › Tutorials[pic][pic]Database Access with the Data Control


[pic][pic]Written By TheVBProgramer.

This tutorial provides a brief introduction to developing database applications with Visual Basic through a series of nine step-by-step exercises. It should be noted that these exercises use the Data control with other controls bound to it. The Data control does a lot for you "behind the scenes" and youmay be tempted to use it in your applications, but be advised that the Data control is rarely used in professional applications – the norm is to write your own database access code so that you have complete control over the process. These exercises are worthwhile in that you can see what data bound controls are all about, but again be advised that they should not be used for professionalapplication development. For further information on why data bound controls are "evil", read this article.


The intrinsic Data control is geared toward MS-Access 97 and earlier databases, although a later VB service pack added connectivity for Access 2000 databases. These articles use the two sample Access databases provided with Visual Basic (BIBLIO.MDB and NWIND.MDB). These databases areprovided in Access 97 format. On a default installation of VB6, these databases can be found in the folder: C:\Program Files\Microsoft Visual Studio\VB98.
To do these exercises, you should make a folder into which you will copy the two database files mentioned above. Then, within the folder you have created, make separate subfolder for each exercise, one level below the root of your folder. TheDatabaseName property for the Data control in these exercises assumes that the database file resides one directory level above the folder in which the exercise project files reside.


Connecting to an Access Database Using the VB Data Control

1. Open a new Visual Basic project.
2. Put a data control (an intrinsic control, located in the VB toolbox) on the formand set the properties as follows:
|Property |Value |
|(Name) |datAuthors |
|Caption |Use the arrows to view the data|
|Connect |Access (default) |
|DatabaseName |..\biblio.mdb |
|DefaultType |UseJet (default)|
|RecordSource |Authors (choose from list) |

Notes: When you use the Data Control in a project, the properties that must be set are DatabaseName and RecordSource, in that order. DatabaseName is the name of the database you want to use, and the...
tracking img