Home > Articles > Programming > .NET and Windows Programming

Connected Operations in ADO.NET

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
In Part 2 of his five-part series on ADO.NET, Dale Michalk discusses ADO.NET connected operations with the Connection, Command, and DataReader classes.
Dale Michalk is an application development consultant for Microsoft Premier Support in Charlotte, NC. He is a regular contributor to InformIT on new technology topics such as .NET and XML.

Connected operations in ADO.NET are data access scenarios that require tight binding and open connection to the data source while working with the connected subset of the ADO.NET object model. This is in contrast to the round-tripping and client manipulation of the DataSet, which is the disconnected data vehicle of choice in ADO.NET.

Those versed in data access with ADO will find the connected operations of ADO.NET familiar ground to tread upon. Microsoft intentionally kept many of the concepts from the previous data access model consistent to aid the programmer in making the transition.

The specific classes discussed in this article are Connection, Command, and DataReader. They work in a very familiar manner to the ADO Connection, Command, and "firehose" cursor Recordset.

NOTE

To download a zip file containing the source files for this article, click here.

Choosing a Provider

The first thing you must do when working with ADO.NET is select the .NET data provider to use for working with your database or data source. If you choose SQL Server for your database, the recommendation is the SQL Server .NET data provider and the classes from the System.Data.SqlClient namespace. If compatibility with OLEDB is required to access a source such as Oracle, the best choice is the OLEDB .NET data provider and the System.Data.OleDb namespace.

For the most part, the two data providers have complementary features. I'll focus mainly on the SQL provider in the following code examples, but will point out differences between the two providers' implementations when necessary. At the end of this article, I'll discuss how to write code that's neutral to either provider.

  • Share ThisShare This
  • Save To Your Account

Discussions

comments powered by Disqus

Related Resources

#TuesdayTrivia: Spotlight on WP7 (Win a copy of Sams Teach Yourself Windows Phone 7 Application Development)
By on May 2, 2012Comments
These days, what CAN'T a smartphone do? Microsoft is putting their own spin on things to help you experience "life in motion" when using your device. Instead of containing static application icons, the re-imagined Start screen features live Tiles showing real-time content updates.

March Trivia #1: Let there be light! (Win Microsoft Visual Studio LightSwitch Unleashed)
By on March 13, 2012Comments
Want a simplified self-service tool to help you build business applications for the desktop and beyond? Microsoft programmers… meet Visual Studio LightSwitch.

February Trivia #2: There's an App for That (Win Sams Teach Yourself iOS 5 Application Development in 24 Hours)
By on February 28, 2012Comments
In less than a decade, the iOS platform has changed the way we think about mobile communication.

See All Related Blogs