[CODE]private SqlDataAdapter da;
private DataSet ds;[/CODE]
[CODE]private void Form1_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.;database=file;uid=sa;pwd=1");
try
{
SqlCommand com = new SqlCommand("select * from aa ", con);
da = new SqlDataAdapter(com);
da.SelectCommand = com;
SqlCommandBuilder cb = new SqlCommandBuilder(da);
ds = new DataSet();
da.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
con.Close();
}
}[/CODE]
[CODE]private void button1_Click(object sender, EventArgs e)
{
try
{
da.Update(ds.Tables[0].GetChanges());
ds.Tables[0].AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}[/CODE]