我使用Visual Studio 2010與SQL數據庫的ExecuteNonQuery()在asp.net不工作
我的C#代碼:
public void Gettotal(int matreqid)
{
int total = 0;
try
{
sqlconnstring = ConfigurationManager.ConnectionStrings["CONERP"].ConnectionString;
sqlcon = new SqlConnection(sqlconnstring);
sqlcon.Open();
sqlcmd = new SqlCommand("GettotalMaterialRequisition", sqlcon);
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlda.SelectCommand.Parameters.Add("@matreqid", SqlDbType.BigInt).Value = matreqid;
sqlcmd.Parameters.Add("@mmtotal", SqlDbType.BigInt).Direction = ParameterDirection.ReturnValue;
sqlcmd.ExecuteNonQuery();
total = Convert.ToInt32(sqlcmd.Parameters["@mmtotal"].Value);
sqlcmd.Dispose();
sqlcon.Close();
}
catch (SqlException sqlerr)
{
}
}
和SQL存儲過程是
ALTER procedure [dbo].[GettotalMaterialRequisition](@mmtotal bigint OUTPUT, @matreqid bigint)
as
begin
set @mmtotal = (select(sum (rate * qty * nooflab)) from MaterialRequisitionList where (matreqid = @matreqid and chkmr = 1))
RETURN @mmtotal;
end
你得到什麼類型的錯誤? – coder