2 w850860027 w850860027 于 2013.11.26 09:43 提问

求大神帮我把这段代码注释下,看不懂啊
        SqlParameter[] arParms = new SqlParameter[2];
        arParms[0] = new SqlParameter("@userid", enamestr);
        arParms[0].Direction = ParameterDirection.Input;
        arParms[2] = new SqlParameter("@right", SqlDbType.VarChar, 1);
        arParms[2].Direction = ParameterDirection.Output;
        SqlHelper.ExecuteNonQuery
        (
                 connectionString,
                 CommandType.StoredProcedure,
                  "p_uis_save",
                  arParms
        );
        string oknot = Convert.ToString(arParms[2].Value);

        //执行存储过程返回返回数据表
        DataSet userds = SqlHelper.ExecuteDataset
        (
        connectionString,
        CommandType.StoredProcedure,
        "p_sys_djget",
        arParms
        );
        System.Data.DataTable table = userds.Tables[0];
        System.Data.DataView view = new System.Data.DataView(table);
        if (view.Count > 0)
        {

        }
    }

2个回答

q894523017
q894523017   2013.11.26 10:38
已采纳

SqlParameter[] arParms = new SqlParameter[2];
arParms[0] = new SqlParameter("@userid", enamestr);
arParms[0].Direction = ParameterDirection.Input;//输入参数
arParms[2] = new SqlParameter("@right", SqlDbType.VarChar, 1);
arParms[2].Direction = ParameterDirection.Output;//输出参数
SqlHelper.ExecuteNonQuery
(
connectionString,//数据库连接
CommandType.StoredProcedure,//类型
"p_uis_save",//存储过程名称
arParms //存储过程参数
);
string oknot = Convert.ToString(arParms[2].Value);//结果

    //执行存储过程返回返回数据表
    DataSet userds = SqlHelper.ExecuteDataset
    (
    connectionString,
    CommandType.StoredProcedure,
    "p_sys_djget",
    arParms
    );
    System.Data.DataTable table = userds.Tables[0];
    System.Data.DataView view = new System.Data.DataView(table);//看下面view.count  ,view 应该是结果集
    if (view.Count > 0)
    {

    }
}

其他的不懂,看代码只是知道这么多。

guomingbing12
guomingbing12   2013.11.26 19:38

怀疑第四/五行数组溢出 arParms[2] = new SqlParameter("@right", SqlDbType.VarChar, 1);
arParms[2].Direction = ParameterDirection.Output;

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!