C#存储过程调用问题

nikita007 2006-05-26 04:25:14
代码不能调用存储过程,调用的代码如下:

try
{

SqlCommand aCommand = new SqlCommand("pr_ProfitPerSupplier",conn);
aCommand.CommandType= CommandType.StoredProcedure;
aCommand.Parameters.Add(new SqlParameter("@strDateFrom",SqlDbType.VarChar,10));
aCommand.Parameters.Add(new SqlParameter("@strDateTo",SqlDbType.VarChar,10));
aCommand.Parameters.Add(new SqlParameter("@intSupplierID",SqlDbType.Int));
aCommand.Parameters.Add(new SqlParameter("@strDivisionID",SqlDbType.VarChar,20));
aCommand.Parameters.Add(new SqlParameter("@strSectionID",SqlDbType.VarChar,10));
aCommand.Parameters.Add(new SqlParameter("@intAttribute",SqlDbType.Int));
aCommand.Parameters.Add(new SqlParameter("@strStore",SqlDbType.VarChar,100));

aCommand.UpdatedRowSource=UpdateRowSource.None;

aCommand.Parameters["@strDateFrom"].Value=strDateFrom.ToString();
aCommand.Parameters["@strDateTo"].Value=strDateTo.ToString();
aCommand.Parameters["@intSupplierID"].Value=intSupplierID;
aCommand.Parameters["@strDivisionID"].Value=strDivisionID.ToString();
aCommand.Parameters["@strSectionID"].Value=strSectionID.ToString();
aCommand.Parameters["@intAttribute"].Value=intAttribute;
aCommand.Parameters["@strStore"].Value=strStore;

aCommand.ExecuteNonQuery();


}
catch
{
MessageBox.Show("excption");
}

存储过程引入参数如下:
CREATE Procedure pr_ProfitPerSupplier
@strDateFrom varchar(10),
@strDateTo varchar(10),
@intSupplierID int = 0 ,
@strDivisionID varchar(20) = '',
@strSectionID varchar(10) = '',
@intAttribute int= 1,
@strStore varchar(100) = ''

...全文
268 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
nikita007 2006-05-26
  • 打赏
  • 举报
回复
谢谢,问题解决了,结贴
nikita007 2006-05-26
  • 打赏
  • 举报
回复
错误就是自己跳到catch中,然后出现excption的提示框
duguguiyu1984 2006-05-26
  • 打赏
  • 举报
回复
有错误信息吗?
nikita007 2006-05-26
  • 打赏
  • 举报
回复
补充:存储过程运行是没问题的,在查询分析器中检查过,只是调用的时候怎么也不能运行存储过程,所以肯定是调用代码的问题,请大家帮忙看看

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧