调用CLR存储过程 [英] Invoking CLR stored procedures

查看:186
本文介绍了调用CLR存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总之,我在哪里可以找到一些argumnet [喜欢的SQLXML数据]调用CLR存储过程,并收到一个DataReader或结果的其他形式的C#/ VB客户端示例代码?



另外我怎么会定期收到来自通过SQlContext.Pipe.Send发送()方法运行CLR存储过程的信息?


解决方案

 字符串的ConnectionString = ConfigurationManager.AppSettings [ConnectDB]; 
SqlConnection的SN =新的SqlConnection(的connectionString);
的SqlParameter [] sqlParameters =新的SqlParameter [1];
sn.Open();
的SqlCommand DCMD =新的SqlCommand(dbo.HelloWorld,SN);
dCmd.CommandType = CommandType.StoredProcedure;
SqlDataReader的RDR = NULL;
RDR = dCmd.ExecuteReader();
,而(rdr.Read())
{
的for(int i = 0; I< rdr.FieldCount;我++)
的Response.Write(RDR [I]) ;
}
sn.Close();
}


In short, where can I find C#/VB client side sample code that calls CLR stored procedure with some argumnet [like a sqlxml data] and receives a datareader or other form of result ?

Also how do I periodically receive information from the running CLR stored proc sent through SQlContext.Pipe.Send() method ?

解决方案

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();
        }

这篇关于调用CLR存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆