偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

歸納ADO.NET 2.0新特性好處

開發(fā) 后端
這里就ADO.NET 2.0新特性使用多數(shù)據(jù)結果集(僅限2005)做出了分析,文章還詳細的分析了ADO2.0的強大功能,希望大家通過看本文能深入了解ADO.NET 2.0新特性。

關注ADO.NET的朋友一定知道ADO.NET 2.0新特性,昨天在圖書館看到一本關于簡介新特性的書,在這里把我的感受分析給大家聽聽。在這篇文章里我將盡量簡單的描述下ADO.NET 2.0的新特性,尤其是配合SQL Server 2005所展現(xiàn)出來的強大實力。如果想進一步了解ADO.NET 2.0編程方面的話,可以去閱讀Glenn Johnson的--"ADO.NET 2.0高級編程。

一:ADO.NET 2.0新特性功能強大的

#T#2005年底(2005年10月)與 SQL Server 2005一起出現(xiàn)的是 .NET Framework 2.0 版本,其中用來訪問數(shù)據(jù)庫的 ADO.NET類也升級到 ADO.NET 2.0 版。ADO.NET 2.0 除了增強舊功能外,也提供了相當多的新功能,包含了以基礎類為本(base-class-based)的數(shù)據(jù)源提供程序(provider)模型、異步訪問架構、批處理更新與大量數(shù)據(jù)復制(bulk copy)、SQL Server 2005 的回調(diào)通知、單一連接同時多執(zhí)行結果集(MARS)、執(zhí)行統(tǒng)計、強化的 DataSet 類等等。換句話說,若要有效發(fā)揮 SQL Server 2005 的功能,前端應用程序最好用 ADO.NET 2.0 來開發(fā)。

ADO.NET 2.0的新特性提供了相當多的新增功能,一些與數(shù)據(jù)源提供程序無關,也就是訪問各種數(shù)據(jù)庫都可以用到的功能,但有很大的一部分是專屬于 SQL Server 2005,針對 SQL Server 2005 的新功能提供給前端應用程序開發(fā)使用。

二: ADO.NET 2.0新特性使用多數(shù)據(jù)結果集(僅限2005)

在之前版本的 SQL Server 同一時間一條連接只能傳遞一個 SELECT 語法執(zhí)行后返回的結果集。如果想在一次連接后返回多個查詢內(nèi)容只能使用類似如下的方法來實現(xiàn):

  1. SqlDataAdapter myDataAdapter = new SqlDataAdapter("StoredProcedureName",myConnection);   
  2. myDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;   
  3. myDataAdapter.SelectCommand.Parameters.Add("@sqlstr",sqlstr);   
  4. DataSet ds = new DataSet();   
  5. myDataAdapter.Fill(ds);  
  6. return ds; ds.Tables[0],ds.Tables[1],ds.Tables[2],//分別對應三個結果集 

SQL Server 2005提供了在同一條連接上可以同時傳遞多個沒有游標結構(cursorless)的結果集(也稱為默認結果集),此功能稱為 Multiple Active Resultsets(MARS)。如此可以節(jié)省需要同時打開的連接數(shù),但要注意的是連接字符串設置要加上 MultipleAct-iveResultSets=true 屬性,否則默認不啟動多數(shù)據(jù)結果集的功能。

  1. string connstr = "server=(local);  
  2. database=northwind;integrated security=true;";   
  3. SqlConnection conn = new SqlConnection(connstr);   
  4. conn.Open(); SqlCommand cmd1 = new SqlCommand("select * from customers", conn);   
  5. SqlCommand cmd2 = new SqlCommand("select * from orders", conn);   
  6. SqlDataReader rdr1 = cmd1.ExecuteReader();   
  7. // next statement causes an error prior to SQL Server 2005 SqlDataReader rdr2 = cmd2.ExecuteReader();   
  8. // now you can reader from rdr1 and rdr2 at the same time. 


 

責任編輯:田樹 來源: 博客
相關推薦

2009-10-29 13:34:01

ADO.NET對象

2009-11-04 15:44:39

ADO.NET Sql

2009-03-12 11:26:35

Data ServicADO.NET.NET

2009-11-13 15:25:51

ADO.NET的對象

2009-11-04 10:35:42

ADO.NET Con

2009-12-23 10:18:21

ADO.NET 應用程

2009-11-12 15:12:57

ADO.NET實體框架

2009-12-24 09:34:47

調(diào)用ADO.NET

2009-12-29 16:02:48

ADO.NET新特性

2009-11-11 15:09:35

ADO.NET數(shù)據(jù)集

2009-12-23 17:54:01

ADO.NET 2.0

2009-11-11 14:44:27

ADO.NET 2.0

2009-11-04 13:20:28

ADO.NET Dat

2009-12-21 13:59:03

ADO.NET特性

2009-12-23 14:59:32

ADO.NET 2.0

2009-11-11 14:58:15

ADO.NET好處

2009-12-30 16:13:52

ADO.NET 2.0

2009-11-11 16:37:50

ADO.NET新增特性

2009-11-13 15:12:54

ADO.NET入門

2011-05-20 11:31:07

ADO.NET
點贊
收藏

51CTO技術棧公眾號