使用存储过程“当前命令发生了严重错误。应放弃任何可能产生的结果”
代码
user.cs
#region//用户发布信息
public int InsertInfor(string Title,string contents,string phone,int type,string inputTime,int School,int SmClass)
{
SqlParameter[] prams = {
IntParam( "@Title ", SqlDbType.VarChar, 50, Title),
IntParam( "@contents ", SqlDbType.Text, 16, contents),
IntParam( "@phone ", SqlDbType.VarChar, 50, phone),
IntParam( "@type ", SqlDbType.Int, 4, type),
IntParam( "@inputTime ", SqlDbType.VarChar, 50, inputTime),
IntParam( "@School ", SqlDbType.Int, 4, School),
IntParam( "@SmClass ", SqlDbType.Int, 50, SmClass),
OutParam( "@InforsID ",SqlDbType.Int,4)
};
RunInsert( "InsertInfor ", prams);
return Convert.ToInt32(prams[7].Value);
//return Convert.ToInt32(prams[0].Value);
}
#endregion
SqlDataBase.cs
#region 创建一个Command来执行存储过程
private SqlCommand ReturnCM(string RunNM, SqlParameter[] PartNM)
{
Open();
SqlCommand ThisCm = new SqlCommand(RunNM,Cn);
ThisCm.CommandType = CommandType.StoredProcedure;
//传入参数
if( PartNM != null)
{
foreach (SqlParameter parmt in PartNM)
ThisCm.Parameters.Add(parmt);
}
//加入返回参数
ThisCm.Parameters.Add