怎样调用textBox自己写的存储过程?急啊!!!! mycommand.commandtype = CommandType.StoredProcedure ; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SQL语句:create procedure textBox1(@a int,@b int,@c int,@d int) as insert TABLE_relation_rc(id,roleid,layerid,LayerContent) values(@a,@b,@c,@d)go只是一条创建存储过程的通用SQL语句。要执行此文本不能使用:mycommand.commandtype = CommandType.StoredProcedure ;另外,我没有重现你的错误提示。但当TextBox控件中的文本包含您的SQL语句中的 Go 时,将出现异常。原因是:create procedure textBox1(@a int,@b int,@c int,@d int) as insert TABLE_relation_rc(id,roleid,layerid,LayerContent) values(@a,@b,@c,@d)go在SQL查询分析器中 go 在单独一行中,而在TextBox控件的Text属性中成了:create procedure textBox1(@a int,@b int,@c int,@d int) as insert TABLE_relation_rc(id,roleid,layerid,LayerContent) values(@a,@b,@c,@d) go此语句有语法问题。就在 go 处。 把“go”去掉,然后SqlCommand myCommand;myCommand=new SqlCommand(textBox.Text,MyConn); myCommand.ExecuteNonQuery(); 上边是创建存储过程,下边是调用:mycommand.commandtype = CommandType.StoredProcedure ;myCommand.commandtext="exec textBox1 "+参数myCommand.ExecuteNonQuery(); 试一试看看。 to weifj() 我的go前面是加了回车了,但还是提示系统错误。 Dim cmd As New SqlCommand cmd.Connection = SqlConnection2 cmd.CommandType = CommandType.Text Dim strStore As String strStore = "create procedure textBox1(@a int,@b int,@c int,@d int) " & _ " as insert TABLE_relation_rc(id,roleid,layerid,LayerContent) " & _ " values(@a,@b,@c,@d)" cmd.CommandText = strStore SqlConnection2.Open() cmd.ExecuteNonQuery() SqlConnection2.Close()测试成功 VB C# 可以通信的AES加密算法 dev TreeList绑定多张表 急!!关于c#Socket分包发送数据的问题(同步) 如何在C#中向系统发送一个等待的消息? 做个流量统计报表,要用到条形图、丙图、曲线图,高手来指点下!! ----------------有谁知道中央一台至九台的其中的电视源(现在小弟急需)------ vs2010启动时提示未能加载文件或程序集..... C#正则表达式问题 关于GZ文件的解压 反射中PropertyInfo.GetValue出错,参数计数不匹配 能否用c#开发activeX控件否? 高手请进:一个关于WinForm反射的超难问题。(见里面)
go
只是一条创建存储过程的通用SQL语句。要执行此文本不能使用:
mycommand.commandtype = CommandType.StoredProcedure ;另外,我没有重现你的错误提示。但当TextBox控件中的文本包含您的SQL语句中的 Go 时,将出现异常。原因是:
create procedure textBox1(@a int,@b int,@c int,@d int) as insert TABLE_relation_rc(id,roleid,layerid,LayerContent) values(@a,@b,@c,@d)
go
在SQL查询分析器中 go 在单独一行中,而在TextBox控件的Text属性中成了:
create procedure textBox1(@a int,@b int,@c int,@d int) as insert TABLE_relation_rc(id,roleid,layerid,LayerContent) values(@a,@b,@c,@d) go
此语句有语法问题。就在 go 处。
SqlCommand myCommand;
myCommand=new SqlCommand(textBox.Text,MyConn); myCommand.ExecuteNonQuery();
上边是创建存储过程,下边是调用:
mycommand.commandtype = CommandType.StoredProcedure ;
myCommand.commandtext="exec textBox1 "+参数
myCommand.ExecuteNonQuery();
试一试看看。
cmd.Connection = SqlConnection2
cmd.CommandType = CommandType.Text
Dim strStore As String
strStore = "create procedure textBox1(@a int,@b int,@c int,@d int) " & _
" as insert TABLE_relation_rc(id,roleid,layerid,LayerContent) " & _
" values(@a,@b,@c,@d)"
cmd.CommandText = strStore
SqlConnection2.Open()
cmd.ExecuteNonQuery()
SqlConnection2.Close()测试成功