使用 XmlReader 檢索 XML 數據
如何使用存儲過程輸出參數來檢索單個行
借助於命名的輸出參數
void GetProductDetails( int ProductID
out string ProductName
{
using( SqlConnection conn = new SqlConnection(
{
// Set up the command object used to execute the stored proc
SqlCommand cmd = new SqlCommand(
cmd
// Establish stored proc parameters
// @ProductID int INPUT
// @ProductName nvarchar(
// @UnitPrice money OUTPUT
// Must explicitly set the direction of output parameters
SqlParameter paramProdID =
cmd
paramProdID
SqlParameter paramProdName =
cmd
paramProdName
SqlParameter paramUnitPrice =
cmd
paramUnitPrice
conn
// Use ExecuteNonQuery to run the command
// Although no rows are returned any mapped output parameters
// (and potentially return values) are populated
cmd
// Return output parameters from stored proc
ProductName = paramProdName
UnitPrice = (decimal)paramUnitPrice
}
}
使用存儲過程輸出參數來檢索單個行
注 一種良好的習慣做法是顯式設置所有參數(包括輸入參數)的方向
[
From:http://tw.wingwit.com/Article/program/net/201311/15093.html