2010-07-28 49 views
0

如果我們選擇大量行並使用SqlDataReader,它會在它們到來時返回行還是等待操作完成?SqlDataReader返回行

這是與C#.net

回答

1

它會返回行,因爲他們來了。每次調用SqlDataReader.Read();時,都會從客戶端的網絡緩衝區中檢索下一行。每個Read()上只有一行保存在內存中。

// Starts getting the data from the query 
IDataReader reader = cmd.ExecuteReader(behavior); 

// Calling .Read() will get the next result from the client network buffer 
while (reader.Read()) 
{ 
    // Do something with the row data 
} 

更多信息here

+0

是說它會一次返回它們全部。 – msarchet 2010-07-28 15:06:44