浩子

在.NET的世界里徜徉

导航

不要忘了关闭你的数据库连接

前面写的水晶报表数据绑定代码中,有一个纰漏,就是没有关闭数据集,非常抱歉。
在进行完 DataSet 的数据集填充后,请不要忘了显式的关闭你的数据集。

如:

string sConnectionString = ConfigurationSettings.AppSettings["dbConnISMS"];

SqlConnection sqlConn = new SqlConnection(sConnectionString);
SqlCommand sqlComm = new SqlCommand();
SqlDataAdapter dataAdapter = new SqlDataAdapter();

sqlConn.Open();

sqlComm.Connection = sqlConn;
sqlComm.CommandType = CommandType.Text;

dataAdapter.SelectCommand = sqlComm;

Dataset1 dataSet = new Dataset1();

string sSQL = "SELECT * FROM T_REQUEST WHERE APPLI_ID = '" + appli_id + "'";

sqlComm.CommandText = sSQL;
dataAdapter.Fill(dataSet, "T_REQUEST");

sSQL = "SELECT * FROM T_REQUEST_INSPECTION WHERE APPLI_ID = '" + appli_id + "'";

sqlComm.CommandText = sSQL;
dataAdapter.Fill(dataSet, "T_REQUEST_INSPECTION");

sSQL = "SELECT * FROM T_ACCEPT WHERE APPLI_ID = '" + appli_id + "'";

sqlComm.CommandText = sSQL;
dataAdapter.Fill(dataSet, "T_ACCEPT");

sSQL = "SELECT * FROM T_ACCEPT_INSPECTION WHERE APPLI_ID = '" + appli_id + "'";

sqlComm.CommandText = sSQL;
dataAdapter.Fill(dataSet, "T_ACCEPT_INSPECTION");

sqlConn.Close();

oRpt.SetDataSource(dataSet);

oViewer.ReportSource = oRpt;

posted on 2004-12-04 17:46  浩子  阅读(1817)  评论(6编辑  收藏  举报