finally
{
reader
// CommandBehavior enum used when generating the reader
}
}
使用 SqlDataReader 檢索行
如何使用 XmlReader 檢索多個行
可以使用 SqlCommand 對象來生成 XmlReader 對象
public void RetrieveAndDisplayRowsWithXmlReader()
{
using( SqlConnection conn = new SqlConnection(connectionString) )
{;
SqlCommand cmd = new SqlCommand(
cmd
try
{
conn
XmlTextReader xreader = (XmlTextReader)cmd
while ( xreader
{
if ( xreader
{
string strOutput = xreader
strOutput +=
strOutput += xreader
Console
}
}
xreader
// used within a using keyword
}
}
上述代碼使用了以下存儲過程
CREATE PROCEDURE DATRetrieveProductsXML
AS
SELECT * FROM PRODUCTS
FOR XML AUTO
GO
[
From:http://tw.wingwit.com/Article/program/net/201311/15092.html