日期:2014-05-17 浏览次数:20731 次
private void UpdateDataGridView(DataGridView dataGridView1)
{
string sql = "select *** from TABLE where *** ";
try
{
DataTable dt = new DataTable();
using (SqlConnection conn = new SqlConnection("***"))
{
conn.Open();
using (SqlDataAdapter adp = new SqlDataAdapter(sql, conn))
{
using (SqlCommandBuilder scb = new SqlCommandBuilder(adp))
{
adp.Fill(dt);
adp.Update(dt);
dataGridView1.DataSource = dt;
dataGridView1.Refresh();
}
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString(), "Information");