In this step, you will use a wizard to set up the database connection and the data set, including telling it the name of the database to use.
- If the Toolbox is not displayed, from the View menu choose Toolbox.
- Click the Data tab to display the available data controls.
- Double-click the BindingSource control to add it to your project.
The BindingSource control is added to your form, in a new area created below the visible area of the form. The data controls added in this tutorial will all be placed in this area, instead of in the visible area of the form.
- If the Properties window is not displayed, press F4 to display the properties for the BindingSource control.
- In the Properties window, click the DataSource property. Then click the drop-down button on the right side of the property setting area.
- In the pop-up dialog that is displayed, choose Add Project Data Source. The Data Source Configuration Wizard appears.
Next, you will follow these steps to set up your database connection and data set in the wizard.
- Under Choose a Data Source Type, choose Database, then click Next.
- Under Choose a Database Model, choose Dataset, then click Next.
- Under Choose Your Data Connection, choose an existing data connection or click New Connection to display the Add Connection dialog.
- If you are adding a new connection,
- If necessary specify the data source as a Microsoft Access Database File, then click Browse to browse to the file at \Program Files (x86)\GrapeCity\Spread.NET 11\Docs\Windows Forms\TutorialFiles\databind.mdb and then click Open.
- Click the Test Connection button.
- If you do not receive a message stating the "Test connection succeeded" retry these steps. If you received the message "Test connection succeeded," your connection is complete. Click OK to close the Add Connection dialog.
- In the wizard, click Next.
- Visual Studio displays a dialog that asks if you want to copy the database file to your project. Choose No.
- Under Save the Connection String to the Application Configuration File, make sure the box for Yes, save the connection as is checked, and accept the default name by clicking Next.
- Under Choose Your Database Objects, click the arrow next to Tables to drop-down the list of available tables. Click the arrow next to Products to display the list of fields in the Products table.
- In the list of fields, select the following fields:
- ProductName
- ProductDescription
- UnitPrice
- LeadTime
- Click Finish.
The DatabindDataSet control is added to your project.