Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
9Activity
0 of .
Results for:
No results containing your search query
P. 1
Visual Basic Database Connectivity Guide 315

Visual Basic Database Connectivity Guide 315

Ratings:

4.5

(2)
|Views: 393 |Likes:
Published by darshanit

More info:

Published by: darshanit on Jul 30, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/24/2010

pdf

text

original

 
 
Page 1
Visual Basic Database Connectivity
An Introductory Guide
Create the VB .Net Application
Create a blank VB .Net solution in your account and add a newproject to the solution. This should automatically create a blank form for you. Also copy the
Authors.mdb
database file from theCOMP315 library folder into your account.
Using Data Adapters and Data Sets
To manipulate data in an access database you need to use a dataadapter to connect to the database and a data set to manipulatethe data.
Creating the Data Adapter 
To create a Data Adapter that contains the SQL statement youwant to populate the dataset with, do the following:Click on the 'Data' tab in the tool box and then double click on the
OleDbDataAdapter
control to add it into the form. The DataAdapter Configuration Wizard will automatically appear to helpyou configure the Data Adapter.
Figure 1. Location of the Data tab in the toolbox.
Click on
Next>
to move to the next screen. Now the Dataconnection to use box should be blank so click on the
NewConnection
button to configure the new connection. Select the
Provider
tab and then select
Microsoft Jet 4.0 OLE DB Provider
 and then click on
Next>
.The Data tab
 
 
Visual Basic Database Connectivity GuidePage 2
In section 1 where it asks for the database to use, click on the '
…'
  button and then navigate to and select the
Authors.mdb
databaseand click on the
Open
button.. Leave section 2 as it is. Yourscreen should look similar to this:
Figure 2. Completed Data Link Properties.
Click on the
Test Connection
button and you should get amessage saying 'Test Connection Succeeded'. If you don’t thencheck you have followed the instructions above. Click on
OK
toreturn to the Data Adapter Wizard and then click on the
Next>
 button.Make sure that
Use SQL statements
is selected and then click onthe
Next>
button.In the large text box type in the following SQL statement:
Select * from authors
Then click on the
Next>
button and then the
Finish
button. Youmay be asked if you want to include a password in the connection
 
 
Visual Basic Database Connectivity GuidePage 3
string, so just click on
Don’t Include Password
. You should nowsee a new Adapter object and a new Connection object.
Creating the Dataset
The next step is to create a Dataset class based on the query youspecified above. Make sure that your Data Adapter object isselected and at the bottom of the properties pane click on the
Generate Dataset…
link and you should see the window belowappear.
Figure 3. The Generate Dataset window.
Select 'New' data set rather than 'Existing' data set and give it thename
dsAuthors
and make sure the 'Add This Dataset to theDesigner' option is selected. Click on the
OK
button to generatethe authors dataset and you should see the Dataset object'dsAuthors1' added to your project.
Adding a Data Grid Control
Now you need to add a data grid control to your form. Do this byselecting the Windows Forms tab in the tool box and then doubleclick on the Data Grid control in the toolbox to add it to yourform. Move it around and make it bigger.

Activity (9)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Maximo Ginez III liked this
felixok liked this
SOPOL liked this
Kristian Saccuan liked this
ozdragon88 liked this
rungta2020 liked this
durgathapa liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->