1 / 33

What’s New in ADO.NET 2.0

What’s New in ADO.NET 2.0. Julie Lerman The Data Farm www.thedatafarm.com jlerman@thedatafarm.com. Julie Lerman. Independent Software Developer 20 years developing Microsoft .NET MVP ASPInsider Various publications & conferences Blog: www.thedatafarm.com/blog

shasta
Download Presentation

What’s New in ADO.NET 2.0

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What’s New in ADO.NET 2.0 Julie Lerman The Data Farm www.thedatafarm.com jlerman@thedatafarm.com

  2. Julie Lerman • Independent Software Developer • 20 years developing • Microsoft .NET MVP • ASPInsider • Various publications & conferences • Blog: www.thedatafarm.com/blog • Founder and leader of Vermont .NET • INETA Advisory Board Member What’s new in ADO.NET 2.0 Julie Lerman

  3. Overview • ADO.NET API is Evolving • It is not being overhauled • Backward compatible to ADO.NET 1.x • SqlClient has close ties to SQL Server 2005 What’s new in ADO.NET 2.0 Julie Lerman

  4. Agenda • Across the board changes in ADO.Net 2.0 • Usability • Flexibility • Power and performance • Changes to SQLClient namespace • Leveraging SQL Server 2005 features Demos will be on VS2005 Beta2 & SQL Server 2005 Developer April CTP This box is 1.6 Ghz , 1 GB RAM What’s new in ADO.NET 2.0 Julie Lerman

  5. EVOLUTION:Usability & Flexibility • DataTable becomes iXMLSerializable • DataTable/DataSet.Load Method • Convert from and to DataReader • Dataview.ToTable Method • Rowstate.SetAdded/SetModified • Provider Independent API What’s new in ADO.NET 2.0 Julie Lerman

  6. DataTable Grows Up • DataTable – IXMLSerializable • No longer dependent on DataSet for • ReadXML & WriteXML • Transfer via Web Services • Merge • Merge multiple DataTables • Note: CANNOT merge DataRow Collections What’s new in ADO.NET 2.0 Julie Lerman

  7. Stream Data into DataTable & DataSet • DataSet/DataTable.Load • Populate a DataTable/DataSet from a DataReader • Load from dbDataReaders • OLEleDbDataReader • SqlDataReader • DataTableReader* • Etc. • Internal function of DataAdapter now exposed • Allows more granular control • Enables DataTable & DataSet Merge functionality with DataReaders • LoadOption (also new to DataAdapter) to deal with concurrency issues What’s new in ADO.NET 2.0 Julie Lerman

  8. DataTableReader • Inherits from dbDataReader • Forward only container for DataTable(s) data • Get a DataReader from a DataTable/DataSet • DataSet/DataTable.CreateDataReader Method • Iteration without a database connection • Populating list controls and more • Navigate similar to SqlDataReader • Read (to next record) • NextResult (to next resultset) • Handles changes to underlying data source well What’s new in ADO.NET 2.0 Julie Lerman

  9. DEMODataTableReaders, DataSetLoad What’s new in ADO.NET 2.0 Julie Lerman

  10. DataView.ToTable • Create a DataTable from a DataView! • Rather than building from iteration or a new database query • DistinctRows parameter is a small blessing What’s new in ADO.NET 2.0 Julie Lerman

  11. DEMODataView.ToTable(DistinctRows) What’s new in ADO.NET 2.0 Julie Lerman

  12. RowState • DataRow.RowState is no longer read only • “Unchanged” rows can be modified • SetAdded • SetModified • DataRowState enums • Added, Deleted, Detached, Unchanged, Modified What’s new in ADO.NET 2.0 Julie Lerman

  13. DEMORowState.SetAdded, SetModified What’s new in ADO.NET 2.0 Julie Lerman

  14. Provider Independent API • Database Independent Coding • System.Data.Common Namespace • Provider Factory Class • Flip in database type at run time • Current Factories • OleDBFactory • OdbcFactory • SQLClientFactory • OracleClientFactory What’s new in ADO.NET 2.0 Julie Lerman

  15. Using Provider Independent APIs ‘example APINameSpace=“System.Data.SQLClient” Public Function GetDS(byVal APINameSpace as String)as DataSet Dim provider as DbProviderFactory = dbProviderFactories.GetFactory(APINameSpace) Dim connection As DbConnection-provider.CreateConnection Dim adapter as DbDataAdapter = provider.CreateDataAdapter ‘code to connect command, connection and dataadapter… adapter.fill(ds) Return ds End Function What’s new in ADO.NET 2.0 Julie Lerman

  16. DEMOIndependent Data Providers What’s new in ADO.NET 2.0 Julie Lerman

  17. EVOLUTION:Performance • Batch Updates • True Binary Serialization for Remoting What’s new in ADO.NET 2.0 Julie Lerman

  18. Batch Updating • Works with DataAdapter.UpdateCommand • Sends groups of queries to the database • Fine Tune based on client and network resources • Time to build multiple queries • Network latency • Processor • Connection pooling • Better control on web servers than deployed smart client apps (can’t pre-determine resources) What’s new in ADO.NET 2.0 Julie Lerman

  19. News Flash!February CTP Batching Screams! Batch Update:Bigger is not always Better! Speed of 10,000 Record Update Speed of 100 Record Update Batch Size Batch Size Not official benchmarks. Based on my own tests Local=SQL2005 Remote Hard Wired=SQL2000 Web=SQL2000 What’s new in ADO.NET 2.0 Julie Lerman

  20. Binary Serializaton in Remoting • V1.x • DataSet is still xml • V2.0 • DataSet is truly serialized as binary • Major performance benefit with large amounts of data What’s new in ADO.NET 2.0 Julie Lerman

  21. EVOLUTION:SQL Server 2005 Integration • Flexibility • SQLDependency and SQLNotification • Usability • MARS (Multiple Active Resultsets) • Reuse Connections • Performance • Asynchronous SQL Command • Bulk Copy What’s new in ADO.NET 2.0 Julie Lerman

  22. SQL Server Query Notification • Tied into SQL Server Service Broker (2005) • System.Data.SQLNotification • System.Data.SqlDependency • ASP.NET has it’s own implementation • System.Web.Caching.SqlCacheDependency • Backwards compatible to SQL7 & SQL 2000 through polling • Use wisely What’s new in ADO.NET 2.0 Julie Lerman

  23. Query Notifications cont. • Many rules and caveats • Most common • Select explicit columns, never select * • Use two part table names: dbo.authors, person.contact • Turn on Service Broker in your database ALTER DATABASE AdventureWorks SET ENABLE_BROKER ; • Grant Notification Permissions to specific database GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [GEEBES\SQLServer Users] • Grant NotificationErrorsQueue Perms to user GRANT RECEIVE ON dbo.[QueryNotificationErrorsQueue] TO [GEEBES\SQLServer Users] What’s new in ADO.NET 2.0 Julie Lerman

  24. DEMOQuery Notification and Caching What’s new in ADO.NET 2.0 Julie Lerman

  25. MARS • Enable reuse of database connections • Off by default (beta2 still has it on) • MultipleActiveResultSets=false in connection string to turn off • Benefits • Multiple SqlDataReaders on one connection • Allows multiple updates in one transaction • note: System.Transactions.TransactionScope • Interleave read with update on one connection • Caveats • Possible performance costs compared to connection pooling What’s new in ADO.NET 2.0 Julie Lerman

  26. Asynchronous Command Object • Great for middle tier • Keep working while waiting for a command to complete processing What’s new in ADO.NET 2.0 Julie Lerman

  27. DEMOAsynchronous Command What’s new in ADO.NET 2.0 Julie Lerman

  28. Bulk Copy • Load data into SQL Server via ADO.NET • Nearly as fast as DTS! • Sample: Loading 104,225 records into SQL2005 What’s new in ADO.NET 2.0 Julie Lerman

  29. DEMOBulk Copy What’s new in ADO.NET 2.0 Julie Lerman

  30. Conclusion • ADO.NET Team says: • We like ADO.NET and want to keep it! • API stays consistent in it’s design • ADO.NET 2 improves on • Usability • Flexibility • Performance • ADO.NET 2.0 was designed in tandem with SQL Server 2005 for powerful results What’s new in ADO.NET 2.0 Julie Lerman

  31. Resources • What’s New in ADO.NET 2.0 • Julia Lerman, MSDN Magazine April 2005 • Caching Improvements in ASP.NET WhidbeyG. Andrew Duthie, MSDN Online February 2004 • Improved Caching in ASP.NET 2.0Stephen Walther, MSDN Online, June 2004 • Asynchronous Command Execution in ADO.NET 2.0Pablo Castro, MSDN Online, July 2004 • ADO.NET and System.Xml v.2.0 – The Beta VersionAlex Homer, Dave Sussman, Mark Fussell, Addison-Wesley, March 2005 • New Features for Web Service Developers in Beta 1 of the .NET Framework 2.0Elliot Rapp,Yasser Shohoud and Matt Travis, MSDN Online, July 2004 What’s new in ADO.NET 2.0 Julie Lerman

  32. Resources cont. • Using CLR Integration in SQL Server 2005Multiple Authors from Microsoft Corporation, MSDN Online, Nov 2004 • ADO.NET 2.0 Multiple Active Result Sets per connection in Sql Server 2005 (MARS) FAQAngel Saenz-Badillos, Weblog Post, Sept 7, 04 (blogs.msdn.com/angelsb) • Transaction Processing in ADO.NET 2.0William Ryan, Sept 14, 2004, 15 Seconds website (www.15seconds.com) • Query Notifications in ADO.NET 2.0Bob Beauchemin, MSDN Online, September 2004 What’s new in ADO.NET 2.0 Julie Lerman

  33. Contact Info Julie Lerman jlerman@thedatafarm.com www.thedatafarm.com www.thedatafarm.com/blog What’s new in ADO.NET 2.0 Julie Lerman

More Related