ARTICLE

How to Create a Strongly Typed DataSet

Posted by Mukesh Kumar Articles | ADO.NET in C# June 27, 2011
In this article we are going to see how to create a Strongly Typed DataSet using the Visual Studio .NET IDE.
Reader Level:
Download Files:
 


In this article we are going to see how to create a Strongly Typed DataSet using the Visual Studio .NET IDE .

Follow these steps to create a Strongly Typed DataSet :

  1. In Visual Studio .NET 2008/2010, click File > New > Project.
     
  2. Select your desired programming language and then select the Console Application template.
     
  3. Right-click on the project in Solution Explorer and click Add > New Item. On the Add New Item dialog select DataSet from the items list. Name the DataSet StronglyTypedDataSet.xsd. Click on Add button to create the DataSet.

    DataSet1.gif
     
  4. Now, If you do not already have a Database Connection, create a new one > Open Server Explorer by selecting View > Server Explorer from the main menu. Right click on the Data Connections node and select Add Connection from the context menu.

    DataSet2.gif
     
  5. In the next dialog box, select the SQL Server. In the Add Connection dialog select Server name.

    Under Log on to the server, do one of the following:

    • Click Use Windows Authentication to use your current Windows user name and password.
    • Click Use SQL Server Authentication and then type your user name and password in the corresponding User Name and Password boxes.

    Here we are using log on mode as Windows Authentication.

    Under Connect to a database select or enter a database name. We are using AdventureWorks database. Click on Test Connection button and then OK button to create the connection.

    DataSet3.gif
     
  6. Now expand the Tables node in Server Explorer for the Data Connection that you just added. Select the Customer (Sales) and CustomerAddress (Sales) tables and drag them onto the DataSet Designer surface.
     
  7. This adds both tables to the strongly typed DataSet. If you don't want all of the columns in a table, expand a table and drag just the columns you need onto the design surface. The designer now shows the two tables together with the data relation between the tables.

    DataSet4.gif
     
  8. The strongly typed DataSet is complete and you can now use it.

Login to add your contents and source code to this article
post comment
     
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.