cmd.Connection.Open();
                SqlParameter[] prams =
                {
new SqlParameter("@house_typeID", SqlDbType.VarChar, 50),
          new SqlParameter("@type_names",  SqlDbType.VarChar, 50),
           new SqlParameter("@type_re",  SqlDbType.VarChar, 50),
          new SqlParameter("@proc_info", SqlDbType.VarChar, 50, ParameterDirection.Output,true, 0, 0, string.Empty,DataRowVersion.Default, null)
};
                prams[0].Value = cf.id;
                prams[1].Value = cf.name;
                prams[2].Value = cf.re;
                // 添加参数
                foreach (SqlParameter parameter in prams)
                {
                    cmd.Parameters.Add(parameter);
                }
                cmd.ExecuteNonQuery();
                string strResult = cmd.Parameters["@proc_info"].Value.ToString();  我想知道 那句红下划线 sqlparameter的参数 proc_info 是什么意思?
   还有为什么我刚才调试的时候 strResult 是“ok”? 

解决方案 »

  1.   

    proc_info 是存储过程名
    strRusult 是执行存储过程 如果存储过程是正确的,当然调试返回值是ok
      

  2.   

      "@proc_info" 这东西是不是固定死的  其实我调试的时候大概猜到这个意思了   
      

  3.   

    "@proc_info" 这东西是固定死的 在存储过程里面写的
      

  4.   

    @proc_info 是存储过程中定义的一个output参数传入参数的时候需要指定该参数的ParameterDirection=ParameterDirection.Output
    new SqlParameter("@proc_info", SqlDbType.VarChar, 50, ParameterDirection.Output,true, 0, 0, string.Empty,DataRowVersion.Default, null)
    等存储过程执行完毕,就可以用这个output参数获取存储过程的output返回值了。
    string strResult = cmd.Parameters["@proc_info"].Value.ToString();使用场景:
    比如你做一个SQL分页查询就需要用到这样的output参数
    存储过程返回查询当前页的数据,output总数据条数。(你需要两个返回值)C#中的out参数和ref参数亦是如此。