C#存储过程调用问题
代码不能调用存储过程,调用的代码如下:
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) = ''