急用 我做的是一个窗体的数据查询 一点机刷新后就会关闭窗体?
刷新触发的事件代码如下: string StrCon = " Data Source= " + DataSource.Text.Trim() + "; Initial Catalog= " + DataBase.Text.Trim() + ";Integrated Security=SSPI";
dataGridView1.DataSource = DataControl.Renew(StrCon).Tables[0]; ;
然后renew的方法代码为:
public static DataSet Renew(string strCon)
{
SqlConnection SqlCon = new SqlConnection();
SqlCon.ConnectionString = strCon;
SqlCon.Open();
DataSet DS = new DataSet();
SqlDataAdapter Adapter = new SqlDataAdapter("select * from StuInfor", SqlCon);
SqlCommandBuilder ComBuild = new SqlCommandBuilder(Adapter);
Adapter.Fill(DS, "StuInfor");
Adapter.Update(DS);
return DS;
}