Professional: Visual Studio® 2012 by Bruce Johnson

Professional: Visual Studio® 2012 by Bruce Johnson

Author:Bruce Johnson [Johnson, Bruce]
Language: eng
Format: epub
Publisher: John Wiley & Sons
Published: 2012-10-20T17:00:00+00:00


To create a strongly typed DataSet from an existing database, follow these steps:

1. Right-click on the project in Solution Explorer and select Add -> New Item.

2. Navigate to the Data section on the left. You will see a number of choices, including ADO.NET Entity Data Model and DataSet. With ADO.NET, there are two different data models that you can choose to represent the mapping between database data and .NET entities: a DataSet or an Entity Data Model. The Entity Framework (which is used in the Entity Data Model) is covered in Chapter 30, “The ADO.NET Entity Framework.” Double-click the DataSet icon to continue.

3. The link to the database which will be used for this DataSet is determined through the Server Explorer. If you don’t already have a connection to the database that you want to use, you’ll need to add it. At the top of the Server Explorer, there is a Connect to Database button that opens the Add Connection dialog. The attributes displayed in this dialog are dependent on the type of database you connect to. By default, the SQL Server provider is selected, which requires the Server name, authentication mechanism (Windows or SQL Server), and Database name to proceed. There is a Test Connection that you can use to ensure you have specified valid properties.

4. After specifying the connection, the next stage is to specify the data to be extracted. At this stage you can drag the tables and views from the Server Explorer onto the design surface for the DataSet. After you have moved at least one database object onto the DataSet designer, the connection string to the database is saved as an application setting in the application configuration file.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.