请高手指点一下这个函数为什么总出错
public static int KeyIfExists(string strKey,string strVal)
         {
             int retVal = 0;
             DBOperation db=new DBOperation();
             SqlConnection con=db.CreateCon();
             try
             {    
                 con.Open();
                 SqlCommand cmd=new SqlCommand("KeyIfExists",con);
                 cmd.CommandType=CommandType.StoredProcedure;
                 cmd.Parameters.Add("@Tag", SqlDbType.Int).Value = 1;
                 cmd.Parameters.Add("@Key", SqlDbType.VarChar).Value = strKey;
                 cmd.Parameters.Add("@Val", SqlDbType.VarChar).Value =strVal;
                 SqlParameter OutValue = cmd.Parameters.Add("@RetValue", SqlDbType.Int);
                 OutValue.Direction = ParameterDirection.Output;
                 cmd.Parameters["@Class"].Value = 1;//执行到这儿就出错了。
                 cmd.ExecuteReader();
                 int outVal = (int)OutValue.Value;
                 if (outVal == 0)
                     retVal=0;
                 else
                     retVal=1;
                 return retVal;
             }
             catch (
System.Exception )
             {
                 throw;
             }
             finally
             {
                 con.Close();
             }
         }
------解决方案--------------------
@Class这个参数没有Add啊
得象前面一样先Add了来