Download the video screen cam of this tip.
Datasets are a completely disconnected way of passing data between components, functions, or applications. What you may not realize is that the "killer app" for Datasets is Web services.
Datasets live a double life. When used within a .NET application, they can be accessed through ADO.NET object model in a manner similar to accessing recordsets using ADO in the past. But they also can be persisted into XML, complete with relations, and self-describing meta-data without any effort on your part. ADO.NET manages how the dataset is persisted between its in-memory representation and its XML persisted form based on a given situation. When passing a Dataset back from a Web service, ADO.NET serializes the Dataset into XML and sends it along its merry way to the Web service consumer.
To illustrate how easy Visual Studio.NET makes this entire process, I've built a small affiliate management Web service that allows an affiliate's Web site to check on how its affiliate program is going, and the commissions that it is owed by the company running the affiliate program. There are three database tables I created in SQL Server:
The Web site owner can integrate the data from this Web service into his existing customer management application, his accounting application, or into his Web site in whatever way he pleases. Again, the purpose of this is to illustrate how easy it is to create this Web service using Visual Studio.NET. I'll walk through these steps at a fairly high level, so I would encourage you to download the screen cam video showing how I created this project so you can witness the entire process from start to finish. The following are the basic steps:
Notice that the GetAffiliateDetail Web Method returns an instance of dsAffiliatePurchase. How will it do this? We let ADO.NET worry about the details of serializing the Dataset into XML. The first line of code sets the @affiliate paramete
To continue reading for free, register below or login
To read more you must become a member of SearchWinDevelopment.com
');
// -->

r to the value passed into the Web service by the consumer. The second line of code "fills" the instance of the dataset that was added to our Designer Surface into the "purchase" table (which is just a name... in this case it does not have the actual structure of the "purchase" table but was named that since we dragged-and-dropped originally from the Server Explorer in step 4 above). The third line of code then sets the results in the dataset to the return value for the Web Method.
When you compile and test using the Web service Help Page to enter the AffiliateID, you'll see the values of the dataset passed back as serialized into XML.
Again, due to space constraints, I went over the steps at a high level, and would encourage you to download the video screen cam that demonstrates all of these steps more easily than words can express. In a few basic steps, you can expose information from your database to your trading partners, affiliates or potential customers through Web services, ADO.NET and Visual Studio.NET.
But the REAL magic happens in the next several tips, which shows how the XML is then persisted back into an ADO.NET dataset, and how changes to Datasets by the client of the Web service are recorded into Datagrams and sent back to the Web service provider for processing. Stay tuned.
About the Author
[IMAGE]Robert Tabor is a Microsoft Certified Professional in Visual Basic with over six years of experience developing n-tier Microsoft-centric applications for some of the world's most prestigious companies and consulting organizations, such as Ernst & Young, KPMG, Cambridge Technology Partners, Sprint, American Heart Association, and the Mary Kay Corporation. Bob is the author of Microsoft .NET XML Web services by Sams Publishing, and contributes to
SoapWebservices.com and LearnVisualStudio.NET. He is currently working on initiatives within Mary Kay, the second largest eCommerce site in retail volume on the net, of how to utilize .NET within their e-business group.