In .NET we have two kinds of Datasets, one is Typed Dataset and second is Untyped Dataset. Untyped Dataset are create at run time using code but Typed Dataset are created during design time and these exists as a file in your Website. You can add Tables, Views, etc. to Typed Dataset as many as you like. Once you are done, you can create new instance of this Typed Dataset in your code and can use it any way you like. In this article, I will only discuss about How can we create these Typed Dataset in Visual Studio.
Instructions:
- Open Visual Studio and create a website or open any existing one.
- Open Solution Explorer and then right click on your Website and select Add New Item.
- In the Add New Item dialogue, Select Dataset and give it any name you like and click Add.
- If Visual Studio prompts you to add this Dataset in App_Code folder, just click Yes to continue.
- After this Visual Studio will open Dataset Designer for your Newly created Dataset. Now what you have to do is, drag and drop table, views, etc. from Server Explorer to this designer and Visual Studio will do all the work to bind those tables to your Dataset.
- So, to add Tables, open Solution Explorer and then explore your Database there, select the Table you want to add and then drag and drop that Table to Dataset Designer
- After this Visual Studio will show you the Table Columns and a Bind_Data function to fill the Dataset in the Designer.
- If you want to remove or add any column to this, you can do so this as well. Right click on your Table in the Dataset Designer and the select Add->Column. There are some other options as well to select and configure your Dataset table. You can also delete Table here.
Now To Use this Dataset in Code, You can see my Article On How To Use Typed Dataset In Code