简而言之,在哪里可以找到C#/VB客户端示例代码,它用sqlxml数据之类的a网调用CLR存储过程,并接收数据中心或其他形式的结果?
此外,如何定期从通过SQlContext.Pipe.Send()方法发送的正在运行的CLR存储proc接收信息?
发布于 2009-10-30 06:57:40
// run a stored procedure that takes a parameter
public void RunStoredProcParams()
{
SqlConnection conn = null;
SqlDataReader rdr = null;
// typically obtained from user
// input, but we take a short cut
string custId = "FURIB";
Console.WriteLine("\nCustomer Order History:\n");
try
{
// create and open a connection object
conn = new
SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI");
conn.Open();
// 1. create a command object identifying
// the stored procedure
SqlCommand cmd = new SqlCommand(
"dbo.CustOrderHist", conn);
// 2. set the command object so it knows
// to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
// 3. add parameter to command, which
// will be passed to the stored procedure
cmd.Parameters.Add(
new SqlParameter("@CustomerID", custId));
// execute the command
rdr = cmd.ExecuteReader();
// iterate through results, printing each to console
while (rdr.Read())
{
Console.WriteLine(
"Product: {0,-35} Total: {1,2}",
rdr["ProductName"],
rdr["Total"]);
}
}
finally
{
if (conn != null)
{
conn.Close();
}
if (rdr != null)
{
rdr.Close();
}
}
}
}
enter code here发布于 2009-11-03 04:48:22
string connectionString = ConfigurationManager.AppSettings["ConnectDB"];
SqlConnection sn = new SqlConnection(connectionString);
SqlParameter[] sqlParameters = new SqlParameter[1];
sn.Open();
SqlCommand dCmd = new SqlCommand("dbo.HelloWorld", sn);
dCmd.CommandType = CommandType.StoredProcedure;
SqlDataReader rdr = null;
rdr = dCmd.ExecuteReader();
while (rdr.Read())
{
for (int i = 0; i < rdr.FieldCount; i++)
Response.Write(rdr[i]);
}
sn.Close();
}发布于 2009-10-29 05:59:42
https://stackoverflow.com/questions/1641833
复制相似问题