SqlConnection con = new SqlConnection("Data Source=PHILEDA1;Initial Catalog=JGD;Integrated Security=True"); DataSet ds = new DataSet(); string sql = "select * from TransactionDate"; SqlCommand com = new SqlCommand(sql,con); SqlDataAdapter adp = new SqlDataAdapter(com); SqlCommandBuilder comb = new SqlCommandBuilder(adp);
SqlDataAdapter sda;SqlCommandBuilder scb = new SqlCommandBuilder(sda);
sda.Update(ds);
this.dataGridView1.DataSource = ds.Tables[0];
DataSet ds = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter();
string sql = "select * from TransactionDate";
SqlCommand com = new SqlCommand(sql,con);
SqlCommandBuilder comb = new SqlCommandBuilder(adp);
adp.InsertCommand = comb.GetInsertCommand();
adp.UpdateCommand = comb.GetUpdateCommand();
adp.DeleteCommand = comb.GetDeleteCommand();
con.Open();
adp.Update(ds);
con.Close();我这样写有错么?
说DataAdapter.SelectCommand 属性需要初始化
http://topic.csdn.net/u/20100515/20/e78ec082-8c7d-42a0-a5c9-30be285be57e.html
SqlConnection con = new SqlConnection("Data Source=PHILEDA1;Initial Catalog=JGD;Integrated Security=True");
DataSet ds = new DataSet();
string sql = "select * from TransactionDate";
SqlCommand com = new SqlCommand(sql,con);
SqlDataAdapter adp = new SqlDataAdapter(com);
SqlCommandBuilder comb = new SqlCommandBuilder(adp);
con.Open();
adp.Update(ds);
con.Close();