Data Adapter Configuration Wizard
In this section we will create our own data adapter, a built-in feature that comes with Visual Basic .NET and work with it. We will create our own table and access data from the newly created table. To start, create a new database in Access, name it as Books, create a table, Table1 with some columns in it and make sure the database is in the C: drive of your machine. To start creating your own DataAdapter, open a blank form and add a button (Button1) and a DataGrid control to it from the toolbox. Our intention here is to display the table or some columns from the table which we created in Access in the DataGrid control when Button1 is clicked. To display that, click on the Data tab in the toolbox and double-click OleDbDataAdapter object. We are using OleDbDataAdapter here as we are working with an OleDb data source. After you select OleDbDataAdapter from the data tab in the toolbox it gets added to the component tray beneath the form and opens the Data Adapter Configuration Wizard dialogue which looks like the image below.
The DataAdapter Configuration wizard let's you customize your data adapter as you want, example, displaying the whole table or displaying selected columns from the table and so on. Click the next button in the Data Adapter Configuration wizard to select the data connection you want to use. The dialogue that opens look like the image below. It allows you to choose the data connection.
Since we are working with the table we created, click the "New Connection" button in this dialogue box which opens the Data Link properties window. The Data Link Properties window looks like the image below.
In the Data Link properties window, select the Provider tab and select "Microsoft Jet 4.0 OLE DB Provider" from the list of available providers. After selecting the provider, select the Connection tab. Click on the ellipse where it says "Select or enter a database name" and browse for the database on the local drive. Since we are working with our own database (Books.mdb) located on the C: drive select that. Click on the "Test Connection" button to test the connection and if the connection succeeds click OK. Clicking OK display a dialogue box like the image below.
It's at this stage we will generate the SQL Statements to be used with this data adapter. Click next on this dialog box which takes you to another dialogue box like the image below.
It's here we build our SQL Queries. We can display the entire table in the DataGrid or just some columns from the table. To display data, click on the Query Builder button on this dialog box to build your queries. Once you click that button a new dialog box opens up with a list that displays all the tables in the database with which we are working. In this case it displays only one table as we created only one table in the Books database. Select Table1 and click Add. Table1 is added to the Query Builder window. You can select entire table to be displayed in the DataGrid or just some columns. To display entire table in the DataGrid select the checkbox named "All Columns" in the small dialog named "Table1" which automatically builds the SQL statement for us. If you want to display specific columns from the table in the DataGrid check on the columns you want to display. Once you finish with your selection, click next. The dialogue box that opens when you click next looks like the image below.
This dialogue lists the configuration of the data adapter and the results. Click finish to close the Data Adapter Configuration wizard.
That creates the data adapter, DataAdapter1, we need. Next step is to create a DataSet and connect this DataSet to the DataGrid using the DataSource and DataMember properties.
NEXT>> Continue Reading
Popular Posts
-
Now I will show you how to retrieve the data posted from a HTML file in a JSP page. Consider an html page that prompts the user to enter his...
-
Accessing the Standard CGI Variables: To build the successful web application, you often need to know a lot about the environment in which ...
-
INTRODUCTION TO 'C': C is a programming language developed at AT & T's Bell laboratories of USA in 1972.it was designed by d...
-
SQL aliases can be used with database tables and with database table columns, depending on task you are performing. SQL column aliases are u...
-
Learning about Events (Continue) Lets program the Form_Load event. "MsgBox" is Visual Basic command that launch a message box. for...
-
Steps to follow: 1. Write Person.java as shown below in Code-11.3.a under polypackage directory. (You are welcome to do this work using eit...
-
The Command Button's KeyPress, KeyDown and KeyUp Events The events that will be mentioned in the following pages are commonly used, and ...
-
The SQL AVG aggregate function selects the average value for certain table column. Have a look at the SQL AVG syntax: SELECT AVG(Column1) FR...
-
package interfaceexercise; // Define an interface with three abstract methods. // Any class that implements this interface has to // impleme...
-
We will use the Customers table to illustrate the SQL LIKE clause usage: FirstName LastName Email DOB Phone John Smith John.Smith@yaho...
No comments:
Post a Comment