To Documents
Groceries1 Example Directions
Connecting a Database Table to a DataGrid Object Without Writing Code
- Download and unzip the file 
Groceries.zip.
Put the resulting file Groceries.mdb in the folder c:\Database.
 - Create a Windows Application called Groceries1.
 - Add a DataGrid control to Form1.  Name it dgGroceries.
 - Create and configure an OleDbConnection object:
- Select the Data tab in the Toolbox.  Place an OleDbConnection object 
       on the form.  Change its name to connectionObject.
 - Click on the right arrow of the ConnectionString object and select 
       "<New Connection...>".  This brings up the Data Link 
Properties Dialog.
 - On the Provider Tab, select "Microsoft Jet 4.0 OLE DB Provider".
 - Click "Next>>" to move to the Connection Tab.  Select the database as
       c:\Database\Groceries.mdb.  Leave the user name as Admin 
and leave Blank Password checked.
 - Click OK  .
 - Click "Don't Include Password" button.
 
 - Create and configure an OleDBDataAdapter object:
- Find OleDbDataAdapter on the Data tab of the Toolbox and place an 
       instance of it on Form1.  
       This will bring up the Data Adapter Configuration Wizard.
 - Click "Next >" to continue.
 - Select this connection ACCESS.c:\Database\Groceries.mdb 
in the combo box and click on "Next >".
 - Leave "Use SQL Statements" checked and click on "Next >".
 - Enter this SQL statement in the textbox:
SELECT * FROM GroceryList
Then click "Next >".
 - Click "Finish" to apply the settings to the OleDBDataAdapterObject.
 - Change the name of OleDBDataAdapter1 to dataAdapterObject.
 
 - Create and configure the DataSet object corresponding to the SQL
statement
SELECT * FROM PersonData.
- On the main menu, select "Data" and "Generate Dataset..." to bring
       up the Generate Dataset window.
 - Leave "New" checked and enter PersonDataset as the name of the
       dataset.  Leave PersonDataset (dataAdapterObject) checked.  Also leave
       Add this dataset to the designer checked.  Click OK.
 - Change the name of PersonDataset1 to datasetObject.
 
 - Create Form_Load event handler for Form1.  Add this code to it:
   
Dim n As Integer
n = dataAdapterObject.Fill(datasetObject)
then set the DataSource property of the DataGrid object to
the GroceriesList table of datasetObject.
 - Run the project. The DataGrid object should display the
GroceryList table of Groceries.mdb.