现在的位置: 首页 > 综合 > 正文

.net调用有参数的存储过程 返回结果集

2012年08月27日 ⁄ 综合 ⁄ 共 1143字 ⁄ 字号 评论关闭

 

    /// <summary>
    /// 调用过程 返回结果集  
    /// </summary>
    public DataSet callProc(string procName,string paramValue)
    {
        v_connection.Open();
        SqlCommand v_comm = new SqlCommand();
        v_comm.Connection = v_connection;
        v_comm.CommandType = CommandType.StoredProcedure;
        v_comm.CommandText = procName;
        SqlParameter param =v_comm.Parameters.Add("@Year", SqlDbType.VarChar,4);  //传入过程参数 
        param.Value = paramValue;  //传入参数的值
        SqlDataAdapter v_adapter= new SqlDataAdapter();
        v_adapter.SelectCommand = v_comm;
        DataSet v_dataset = new DataSet();
        v_adapter.Fill(v_dataset);
        v_connection.Close();
        return v_dataset;
    }

 

代码很垃圾   但意思表达清楚了 

详细用法参考 http://www.cnblogs.com/clhed/articles/1269415.html

抱歉!评论已关闭.