Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  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 log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

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

Microsoft Touts Xbox 360 'Black Friday' Success

Microsoft this week revealed that its Xbox 360 video game console outsold its Sony PlayStation 3 rival 3-to-1 on "Black Friday," which curiously describes the three day weekend after Thanksgiving, a period that unofficially kicks off the holiday selling ...

How can I stop and start services from the command line?

...


.NET Whitepapers Batch Job Scheduling and .NET in 2008

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

Check out our list of Free Email Newsletters!

Related .NET Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


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 Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing