How to: Connect to Data in a Database
You connect your application to a database by running theand selecting Database on the Choose a Data Source Type page.
Upon completion of the wizard, a dataset is added to your project and is immediately available in thefor dragging onto your form.
Dragging items from the Data Sources window to a form or component results in the creation of several data-related objects, including the connection object. The connection object is located within the TableAdapter associated with the dragged items. For example, if you drag a column from a table named Customers, a TableAdapter named CustomersTableAdapter is created. To view the connection, open the dataset in the Dataset Designer, select the TableAdapter, and view the Connection property in the Properties window. For more information, see .
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see.
To connect your application to a database
On the File menu, create a new project.
On the Data menu, click Add New Data Source.
Select Database on the Choose a Data Source Type page.
Select a data connection from the list of available connections on the Choose Your Data Connection page. If your desired data connection is not available, select New Connection to create a new data connection. For more information on creating a new connection to a database, see one of the following Help pages:
By default, the connection is saved in the application configuration file. Clear the check box to save the connection string directly in the compiled application. For more information, see.
Select the database objects to use in your application.
Replace the default DataSet name, if you want to.
The dataset you just created is now available in the Data Sources window.
Open the Data Sources window by clicking Show Data Sources on the Data menu.
Drag items from the Data Sources window to a form or the.
Storing sensitive information (such as a password) can affect the security of your application. Using Windows Authentication (also known as integrated security) is a more secure way to control access to a database. For more information, see.