我不确定我是否做错了以下代码。 使用静态和实例化sqlConnection并从数据库中检索数据。
public static DataSet GetSiteSummary(DateTime? fromDate, DateTime? toDate)
{
string connectionString = Configuration.DBCon;
DataSet ds = new DataSet();
try
{
SqlConnection con = new SqlConnection(connectionString);
con.Open();
SqlParameter paramFromDate = new SqlParameter("@fromDate", SqlDbType.DateTime);
paramFromDate.Value = fromDate;
SqlParameter paramToDate = new SqlParameter("@toDate", SqlDbType.DateTime);
paramToDate.Value = toDate;
ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "GetSiteSummary", paramFromDate, paramToDate);
con.Close();
}
catch (Exception e)
{
ErrorLog eLog = new ErrorLog();
eLog.InserErrorLog("GetSiteSummary", "System", e);
eLog.Dispose();
}
return ds;
}