当前位置: 代码迷 >> ASP.NET >> 使用存储过程“当前命令发生了严重异常。应放弃任何可能产生的结果”
  详细解决方案

使用存储过程“当前命令发生了严重异常。应放弃任何可能产生的结果”

热度:5695   发布时间:2013-02-26 00:00:00.0
使用存储过程“当前命令发生了严重错误。应放弃任何可能产生的结果”
代码
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(new   SqlParameter( "ReturnValue ",   SqlDbType.Int,   4,
                        ParameterDirection.ReturnValue,   false,   0,   0,
  相关解决方案