就这样
private void button1_Click(object sender, System.EventArgs e)
{
da.Update(_DataSet1,"table1");
}
private SqlCommandBuilder cb;
private SqlDataAdapter da;
private void Form1_Load(object sender, System.EventArgs e)
{
dis();
}
private void dis()
{
string ConStr ="Data Source=;Integrated Security=SSPI;Initial Catalog=lianxi";
// Get Data from multiple tables table
string SQL = "SELECT * FROM table1";
SqlConnection Conn = new SqlConnection(ConStr);
// Create a SqlCommand object
sqlCommand1 = new SqlCommand(SQL, Conn);
// Create a SqlDataAdapter object
da = new SqlDataAdapter();
da.SelectCommand = sqlCommand1;
// Create a SqlCommandBuilder object
cb = new SqlCommandBuilder(da);
// Fill DataSet with data from Employees table
da.Fill(_DataSet1, "table1");
// Bind the DataGrid at run time
dataGrid1.SetDataBinding(_DataSet1, "table1");
}