SIGN UP MEMBER LOGIN:    
ARTICLE

Adding Typed DataSets in ADO.NET

Posted by Mahesh Chand Articles | ADO.NET in C# December 13, 2009
In this article I will explain about Adding Typed DataSets in ADO.NET.
Reader Level:


This article has been excerpted from book "A Programmer's Guide to ADO.NET in C#".

 In the previous article, you way saw how you can generate DataSet objects from a data adapter. There are other ways to create a typed DataSet object.

You can click on the project menu and choose Add New Item (or click Ctrl +D). This brings up the Add New Item window where you'll find the Data Set template (see figure 4-50).

Figure-4.50.gif

Figure 4-50. Creating a typed Dataset from the Add New Item window

After adding the DataSet, the designer creates an XSD (XML schema) file and adds it to your project area. As you can see from figure 4-51, myDS.xsd is empty.

Figure-4.51.gif

Figure 4-51. myDS.xsd in VS.NET

Next drop a table (or multiple tables) from the server Explorer to the form (see figure 4-52).

Figure-4.52.gif

Figure 4-52. Drag and drop tables from the server Explorer to the from to create a typed Dataset

This action adds one XML schema (MyDS.xsd), which looks like figure 4-53.

Figure-4.53.gif

Figure 4-53. Design View of the XML schema of the Dataset

It also automatically adds the typed DataSet class that inherits from DataSet. As you can see in figure 4-54, the myDS class contains members used to access data from the database.

Figure-4.54.gif

Figure 4-54. Wrapper class generated for the typed DataSet

Once you have this class, you can create an instance of this class and work with its property fields directly:


MyDSet ds = new MyDSet();

Conclusion

Hope this article would have helped you in understanding Adding Typed DataSets in ADO.NET. See my other articles on the website on ADO.NET.

adobook.jpg
This essential guide to Microsoft's ADO.NET overviews C#, then leads you toward deeper understanding of ADO.NET.


Login to add your contents and source code to this article
share this article :
post comment
 

hello
when i use dataset  to manipulate data i notice that when i make any change tho the dataset
the change did not reflected to the orginal data

Posted by salama mohammed Oct 11, 2010
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor