I am passing the below parameters from c# form. But getting error. I can not find where the reason is. Please help me.
SqlParameter[] arrParam = new SqlParameter[3];
arrParam[0] = new SqlParameter("@mRegNo", SqlDbType.BigInt, 8);
arrParam[0].Value = Convert.ToInt64(m);
arrParam[1] = new SqlParameter("@amount", SqlDbType.Decimal);
arrParam[1].Value = money;
arrParam[2] = new SqlParameter("@intResult", SqlDbType.Int);
arrParam[2].Direction = ParameterDirection.Output;
int result = objDUT.ExecuteSqlSP(arrParam, "Sp_Add_Moeny");
Here is the function below:
public int ExecuteSqlSP(SqlParameter[] arrParam, string strSPName)
{
OpenConnection();
_mDataCom.CommandType = CommandType.StoredProcedure;
_mDataCom.CommandText = strSPName;
_mDataCom.CommandTimeout = 30;
for (int i = 0; i < arrParam.Length; i++)
{
_mDataCom.Parameters.Add(arrParam[i]);
}
_mDataCom.ExecuteNonQuery();
int intResult = Int32.Parse(_mDataCom.Parameters["@intResult"].Value.ToString());
CloseConnection();
DisposeConnection();
return intResult;
}
Please suggest a solution. Thanks
sp_prefix for your stored procedures. Microsoft has reserved that prefix for its own use (see Naming Stored Procedures), and you do run the risk of a name clash sometime in the future. It's also bad for your stored procedure performance. It's best to just simply avoidsp_and use something else as a prefix - or no prefix at all! - marc_s