c# DataSet 封装代码 读取实例代码
我有一个DataSet 封装代码,之前少用 没有调用,
/// <summary>
/// 执行传入的存储过程名和参数结构体,返回DataSet对象
/// </summary>
/// <param name="strProName"></param>
/// <param name="stProParameters"></param>
/// <returns></returns>
public static DataSet Re_DataSet(string strProName, ProceducreParameter[] stProParameters)
{
using (SqlConnection Conn = new SqlConnection(SqlConn.ConnSting))
{
ConnExsql.Open(Conn);
DataSet ds = null;
using (SqlCommand Cmd = new SqlCommand(strProName, Conn))
{
Cmd.CommandType = CommandType.StoredProcedure;
for (int i = 0; i < stProParameters.Length; ++i)//注意,不是“i++”!
{
ProceducreParameter stProPar = stProParameters[i];
SqlParameter sp = new SqlParameter(stProPar.TabStrName, stProPar.TabStrType, stProPar.TabStrSize);
sp.Direction = stProPar.TabStrDirection;
sp.Value = stProPar.TabStrValue;
Cmd.Parameters.Add(sp);