/// 执行带参数存储过程并返回数据集合
/// </summary>
/// <param name="procName">存储过程名称</param>
/// <param name="parameters">SqlParameterCollection 输入参数</param>
/// <returns></returns>
public static DataTable dataTable(string procName,SqlParameterCollection parameters)
{
SqlDataAdapter da=new SqlDataAdapter();
DataTable datatable=new DataTable();
try
{
openConnection();
comm.Parameters.Clear();
comm.CommandType=CommandType.StoredProcedure ;
comm.CommandText =procName;
foreach(SqlParameter para in parameters)
{
SqlParameter p=(SqlParameter)para;
comm.Parameters.Add(p);
}
da.SelectCommand =comm;
da.Fill(datatable);
}
catch(Exception e)
{
throw new Exception(e.Message);
}
finally
{
closeConnection();
}
return datatable;
}
public static DataView dataView(string sqlstr)
{
SqlDataAdapter da=new SqlDataAdapter();
DataView dv=new DataView();
DataSet ds=new DataSet();
try
{
openConnection();
comm.CommandType=CommandType.Text;
comm.CommandText =sqlstr;
da.SelectCommand =comm;
da.Fill(ds);
dv=ds.Tables[0].DefaultView;
}
catch(Exception e)
{
throw new Exception(e.Message);
}
finally
{
closeConnection();
}
return dv;
}
}
}