请教,急
private void button1_Click(object sender, System.EventArgs e)
{
Process.Start( "rasdial ", "hs zxj10 zxsys ").WaitForExit();
string conn = "user id=sa;data source=\ "209.160.11.129\ ";password=zx564011;initial catalog=ALMSYS ";
SqlConnection thisConn = new SqlConnection(conn);
thisConn.Open();
SqlDataAdapter adapter = new SqlDataAdapter( "Select content from alarm where code=3072 ",thisConn);
MessageBox.Show( "Step1 ");
thisConn.Close();
adapter.Fill(dataset);
MessageBox.Show( "Step 2 ");
dataGrid1.DataSource = dataset;
Process.Start( "rasdial ", "hs /d ").WaitForExit();
}
}
通过vpn连接,取数据库中的数据,然后断开.
第一次点击成功,第二次总是失败,为什么
------解决方案--------------------你自己把连接都关了啊,thisConn.Close(); dapter.Fill(dataset);