110,499
社区成员
发帖
与我相关
我的任务
分享
try
{
//可能会出错的位置
//....
//....
}
catch (Exception ex)
{
//出错后执行的代码
MessageBox.Show(ex.Message);
}
private void button1_Click(object sender, EventArgs e)
{
string constr = "Server=ACER\\SQLEXPRESS;database=Staff;integrated security=true";
SqlConnection con = new SqlConnection(constr);
string select = textBox1.Text;
DataSet ds = new DataSet();
SqlDataAdapter dap = new SqlDataAdapter(select, con);
dap.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}