Provide an example of how to connect a Visual Basic applicat
Provide an example of how to connect a Visual Basic application to a Microsoft Access database and then display the information in one or more controls in the interface
Solution
Step-1 Create a Microsoft Access database
Step-2 Create a Windows application in Visual Basic .NET
(By default, Form1 is created)
Step-3 Open a connection to the Access database
1. On the View menu, click Server Explorer.
2. In Server Explorer, right-click Data Connections, and then click Add Connection.
3. In the Data Link Properties dialog box, click the Provider tab.
4. In the OLE DB Provider(s) list, click Microsoft Jet 4.0 OLE DB Provider, and then click Next.
5. Click the Connection tab, and then click the ellipses button (...).
6. Locate the Access database testdb.mdb file that you created by following the corresponding path on your computer.
7. Select the testdb.mdb file, and then click Open.
8. In the Data Link Properties dialog box, click OK.
Step-4 Retrieve data from the Access database by using the OleDbDataAdapter class
1.On the toolbox, click the Datatab.
2. Drag an OleDbDataAdapter control to Form1.
3. In the Data Adapter Configuration Wizard, click Next three times.
4. In the Generate the SQL statements panel, type the following Microsoft SQL Server statement, and then click Next:
Select * from Student
5. In the View Wizard Results panel, click Finish. Note In the Do you want to include the password in the connection string? dialog box, click Don\'t include password.
6. Right-click OleDbDataAdapter1, and then click Generate Dataset.
7. In the Generate Dataset dialog box, click OK.
8. Add the following code to the Form1_Loadevent handler:
\'Fill retrieves rows from the data source by using the SELECT statement OleDbDataAdapter1.Fill(DataSet11)
