您的位置:程序门 -> .net技术 -> c#



用clr写存储过程,是不是只支持一个sqlconnection?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


用clr写存储过程,是不是只支持一个sqlconnection?[已结贴,结贴人:happy2003]
发表于:2007-02-08 10:24:42 楼主
我这样写代码都会有报错

  sqlconnection   myconnection   =   new   sqlconnection( "context   connection=true ");
  sqlconnection   myconnection1   =   new   sqlconnection( "context   connection=true ");
  myconnection.open();
  myconnection1.open();
发表于:2007-02-08 10:30:221楼 得分:5
肯定支持多个链接

是你代码中   有逻辑错误
发表于:2007-02-08 10:40:002楼 得分:5
支持n个连接

context   connection=true是啥
发表于:2007-02-08 11:34:283楼 得分:0
好像不支持,我在msdn上找到的
http://forums.microsoft.com/msdn/showpost.aspx?postid=68777&siteid=1
叶建   说:
you   can   only   have   one   open   context   connection   at   a   time   within   a   clr   procedure   ( "context   connection=true ").     is   it   possible   that   in   the   missing   code   snippets   for   your   example   (... 's)   that   you   are   attempting   to   open   another   context   connection?   for   instance,   calling   triggers.connection(true)   again   anywhere   prior   to   the   triggers.connection(false)   call   would   result   in   this   exception.   the   call   stack   where   the   "connection   already   in   use "   exception   is   thrown   would   be   useful   to   track   down   this   cause.

2)   june   ctp   has   a   couple   of   bugs   where   an   exception,   especially   if   due   to   an   attention   (i.e.   cancel)   signal,   can   cause   the   connection   to   not   properly   clean   itself   up   from   one   invocation   of   the   procedure   to   the   next.     this   problem   would   not   be   apparent   on   first   invocation   of   the   proc,   and   would   temporarily   be   cleared   by   running   "dbcc   freeproccache ".
发表于:2007-02-08 11:35:424楼 得分:90
好,搶分,i 'm   leafsword
发表于:2007-02-08 11:37:145楼 得分:0
必须
using   (sqlconnection   con   =   new   sqlconnection( "context   connection   =   true "))   {
            con.open();
            ...
    }

and

    using   (sqldatareader   rdr   =   cmd.EXECutereader())   {
            ...
    }
但是如果要在循环里做这个操作就郁闷了


快速检索

最新资讯
热门点击