日期:2014-05-17 浏览次数:20921 次
public DataSet GetDataSet(string strSql, CommandType cmdType, params SqlParameter[] param)
{
using (SqlConnection con = new SqlConnection(connectionStr))
{
SqlDataAdapter sda = null;
try
{
con.Open();
SqlCommand com = new SqlCommand(strSql, con);//strSql参数为:EXEC 存储过程名字 '201302','20130116','20130219','Y'
com.CommandTimeout = 0;
com.CommandType = cmdType;
com.Parameters.AddRange(param);
sda = new SqlDataAdapter(com);
DataSet ds = new DataSet();
sda.Fill(ds,"myDs");//断点位置
return ds;
}
catch (SqlException ex)
{
throw new Exception("SQL数据库连接失败,执行DataSet查询产生错误: " + ex.Message);
}
finally
{
sda.Dispose();
con.Close();
}
&nbs