存储过程如下:
ALTER procedure [dbo].[proc_count]
@count int output
asselect @count = count(*) from [user]在SQL 2005中 调用:
declare @count int
exec proc_count @count output
print @count
go
正常。
在C#程序中调用:
SqlCommand command = new SqlCommand("proc_count",connection);
SqlParameter para = new SqlParameter("@count",SqlDbType.Int);
command.Parameters.Add(para);
para.Direction = ParameterDirection.Output;
command.ExecuteReader();
Console.WriteLine(para.Value.ToString());报错:'proc_count' 附近有语法错误。请高人赐教
ALTER procedure [dbo].[proc_count]
@count int output
asselect @count = count(*) from [user]在SQL 2005中 调用:
declare @count int
exec proc_count @count output
print @count
go
正常。
在C#程序中调用:
SqlCommand command = new SqlCommand("proc_count",connection);
SqlParameter para = new SqlParameter("@count",SqlDbType.Int);
command.Parameters.Add(para);
para.Direction = ParameterDirection.Output;
command.ExecuteReader();
Console.WriteLine(para.Value.ToString());报错:'proc_count' 附近有语法错误。请高人赐教
解决方案 »
- C#长度不确定一维数组的问题
- 如何获取DataSet 或者DataTable中的Title?
- 急:treelistview小计问题!
- 求C#进程间通信方法
- 在vs2005下如何进行方差计算
- C# 创建线程 线程处理完 利用return 返回 但系统句柄始终不释放 在线等大虾指教!
- 急!!怎么将TEXTBOX中写入的一段话。原文分行写在数据库中??
- 利用api得到某应用程序中一个文本框的句柄,有什么方法让这个文本框失去焦点?
- CSDN论坛被人黑了??????
- 关于CLIENT应用COOKIE的问题
- 命令钮原来的名称是Command2,有一个事件是public void Command2_Click(,现在在属性中将该命令钮名称改成了btnAcx,但Command2_Click不会自动改成btnA
- WinForm 怎样连结通过路由器连起来的另一台机子上的access数据库
SqlCommand command = new SqlCommand("proc_count",connection);
SqlParameter para = new SqlParameter("@count",SqlDbType.Int); command.CommandType = CommandType.StoredProcedure; // <-- 调用存储过程 command.Parameters.Add(para);
para.Direction = ParameterDirection.Output;
command.ExecuteReader();
Console.WriteLine(para.Value.ToString());