getcustomerordersclr.cs
来自「C#高级编程第6版随书源代码 值得下载」· CS 代码 · 共 31 行
CS
31 行
using System.Data;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void GetCustomerOrdersCLR(int customerId)
{
SqlConnection connection = new SqlConnection("Context Connection=true");
connection.Open();
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = "SELECT SalesOrderID, OrderDate, DueDate, " +
"ShipDate " +
"FROM Sales.SalesOrderHeader " +
"WHERE (CustomerID = @CustomerID)" +
"ORDER BY SalesOrderID";
command.Parameters.Add("@CustomerID", SqlDbType.Int);
command.Parameters["@CustomerID"].Value = customerId;
SqlDataReader reader = command.ExecuteReader();
SqlPipe pipe = SqlContext.Pipe;
pipe.Send(reader);
connection.Close();
}
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?