Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


February 20, 2003

Basics of the .NET Framework: ADO.NET


RSS
Subscribe to Windows IT Pro | See More .NET Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

You use applications not only to create information but also to recall information you've stored. The part of the .NET Framework that interfaces with databases is called ADO.NET.

Let's review how applications that follow the Microsoft model get data into and out of databases. Microsoft's first multidatabase platform for accessing data was Open Database Connectivity (ODBC), an API that developers writing in C use to interact with relational databases. Microsoft's next step was to extend this access model beyond C-language applications and to provide access to tabled databases through the Common Object Model (COM). Then Microsoft developed a more language-agnostic way of interacting with databases: OLE DB. ODBC didn't go away--OLE DB just provided a means of accessing it from languages other than C.

The catch to OLE DB is that its COM objects aren't available to scripting languages such as VBScript. To let scripts access databases, Microsoft added yet another layer: ActiveX Data Objects (ADO). ADO doesn't replace OLE DB; rather, ADO gives applications that can't use OLE DB a way to interact with databases.

ADO.NET is the .NET version of ADO. ADO.NET adds an extra layer to the data-access cake with the addition of SQL Server and OLE DB managed providers. The data-access path for SQL Server applications goes straight from the managed provider to the database. The data-access path for applications that use OLE DB access goes from OLE DB to ODBC before accessing the database.

The differences between ADO and ADO.NET aren't limited to the path that data takes from the database to the application and back again, however. Here's an overview of how ADO.NET reads and writes data store data.

First, ADO.NET doesn't depend on continuous connections to its databases. Traditionally, client/server application components open a connection to a database and keep it open while the application is open. This approach keeps the data available but strains the database server by requiring it to maintain open connections. If all applications keep open connections, then the number of connections that a database can support limits the number of applications--and instances of applications--that can connect to it. In addition, not all applications are able to maintain live connections to their data stores. Web applications in particular can't rely on a live connection. For these reasons, ADO.NET connects applications to their data stores only long enough to read or write the appropriate data. This connection architecture better supports Web-based applications and makes database-dependent applications scale better.

Second, because ADO.NET uses managed providers, it interacts with its data stores differently than other data-access models do. Applications usually execute SQL statements or stored procedures to read or interact with a database. ADO.NET packages these statements and stored procedures within data commands. For example, if you want to read a set of rows from the database, you create a data command and configure it with the text of a SQL Select statement or the name of a stored procedure that fetches records. The data commands open the connection, execute the SQL statement or stored procedure, and close the connection. If you need to perform more than one operation, you use multiple data commands.

Third, applications that use ADO.NET can cache data in datasets. The idea behind this approach is that applications frequently need not just one record but a set of records. Rather than going back to the database repeatedly for records, one option is to cache the records retrieved from the database and work from this cache. An object in an application can even send its dataset to another part of the application that needs the same data but would have had to query the database itself. To update a database by updating the dataset, an application uses data adapters. A data adapter typically contains four commands, one each to select, insert, update, and delete rows in the database. Datasets aren't specific to a particular database. A dataset can contain information from multiple databases, or one database and one spreadsheet. After data is in the dataset, the data's origin doesn't matter--the application can work with it all in the same way.

Finally, data stored in a dataset is transferred as XML. The ADO.NET data APIs automatically create XML files or streams from information in the dataset and send them to another component, then translate them back as they enter their new dataset. Data isn't stored in the dataset as XML, it's only transferred in XML format to ensure interoperability among applications. In addition, XML is text-based, so it can pass through firewalls that block binary files.

End of Article



Reader Comments
Clear and Brief, good article

Jane Liu December 11, 2003


hi :
sorry,i'm very to make bold;
because i need "building web solution with asp.net and ado md.net" book or any
data.

thanks

Paul Tsai Pocheng January 14, 2004


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
What You Need to Know About Microsoft's x64 Server Product Plans

What do Longhorn Server, Windows Compute Cluster Server, and Windows Vista have in common? The x64 platform. ...

Anti-Virus Vendors Prepare for War with Microsoft ... Again

When Microsoft announced its Windows Live OneCare security and PC health product over five years (as MSN OneCare), Symantec, McAfee, and the other consumer-oriented security vendors reacted with stunning vigor. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...


.NET Whitepapers Global Trends: Unified SOA Performance Management Matters

The role of Service Level Agreements in Successful SOA Deployments

Batch Job Scheduling and .NET in 2008

Related Events DevConnections, Microsoft® ASP.NET Connections, SharePoint Connections and SQL Server Connections

The Easiest Way to Save Time and Money on E-mail and SharePoint Management

Top 11 Reasons Why Oracle Database 11g on Windows is Right For You

Check out our list of Free Email Newsletters!

Related .NET Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format

Test Drive IT Solutions and Get Free Music Downloads
Solve your toughest IT problems with these free downloads and receive 5 free music downloads!


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home asp.netPRO Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement | Reprints and Licensing