News about data-access technology has taken a backseat to server news lately. But that doesn't mean there's no news about ADO.NET. On the contrary, there are several important changes in ADO.NET 2.0. Here are six of the most important changes.
6. Asynchronous Support
Asynchronous support lets client applications submit queries without blocking the UI. ADO.NET 2.0 lets server applications issue multiple database requests on different threads. The support works with SQL Server 2005, SQL Server 2000, and SQL Server 7.0.
The new Multiple Active Result Sets (MARS) feature in ADO.NET 2.0 can have multiple active commands on one connection. By using MARS, you can open a connection to the database, open a new command and process some results, open a second command and process those results, then go back to the first command and process more results. No blocking happens between the commands that share the database connection. You can use MARS support only with SQL Server 2005 systems.
The new ADO.NET provides basic support for paging by letting an application select and bind to a range of rows from a result set. For scalability, the new paging implementation doesn't hold any state on the server, so it doesn't use cursors and there are no locks on the records in the result set. However, this means that it's possible for the paging set's membership in the paged result set's contents to change between executions.
3. Bulk Insert
The SqlBulkCopy object provides a high-performance method for transferring database objects between databases or SQL Server systems. However, the object doesn't connect to the file system and thus can't be used to import flat files to SQL Server.
2. Server-Side Cursors
Server-side cursers let you shift the work of reading through a result set from the client to the server. Microsoft added this feature primarily for the new, in-process SQL Server .NET Data Provider. The in-process Data Provider executes on the server, so using a server-side cursor is acceptable. This support is important because batch processes might need to scroll through a result set with little or no user interaction. In ADO.NET 2.0, the new SqlResultSet object exposes server-side cursors to your Microsoft .NET database objects.
1. Common Connection Model
Unlike ODBC or ADO, in which your applications can choose providers on the fly, ADO.NET forces you to hard-code your application to use a specific provider for the target database platform. For example, the SqlClient can connect only to SQL Server systems, not to Oracle systems. ADO.NET 2.0 adds a new Provider Factory capability that can instantiate the appropriate provider at run time.Corrections to this Article:
- Paging and server-side cursors have been cut from the ADO.NET 2.0 release. The primary scenario for asynchronous support isn't to avoid blocking the UI. The feature lets you perform parallel work (fire a query and continue rendering a Web page or fire multiple queries simultaneously, for example) and for high-end I/O on server applications. For more information about new ADO.NET features see http://msdn.microsoft.com/library/en-us/dnvs05/html/ado2featurematrix.asp