关于数据库更新的问题
各位大哥,帮我看看:gridBindingSource = new System.Windows.Forms.BindingSource(); //生成绑定对象
siteDataSet = new System.Data.DataSet("siteDataSet"); //生成DateSet
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(); //生成命令
= "SELECT * FROM tbSiteInfo";
cmd.Connection = this.tbSiteInfoTableAdapter.Connection;
tbSiteAdapter = new System.Data.OleDb.OleDbDataAdapter(cmd); //生成Adapter对象
System.Data.OleDb.OleDbCommandBuilder oleCmd = new System.Data.OleDb.OleDbCommandBuilder(tbSiteAdapter);
tbSiteAdapter.Fill(siteDataSet, "tbSiteInfo"); //填充DateSet
gridBindingSource.DataSource = siteDataSet;
gridBindingSource.DataMember = "tbSiteInfo"; //为绑定对象设置数据源
siteBindingNavigator.BindingSource= gridBindingSource; //为导航条设置绑定源
//siteBindingNavigator.BindingSource.DataMember = "tbSiteInfo";
textBox1.DataBindings.Add("text", gridBindingSource, "siteName", true);
textBox2.DataBindings.Add("text", gridBindingSource, "H3CIP", true);
textBox3.DataBindings.Add("text", gridBindingSource, "GPSIP", true);
textBox4.DataBindings.Add("text", gridBindingSource, "NASIP", true); /为四个box对象设置绑定
在导航按钮的保存功能中编写了一下代码:
this.Validate();
gridBindingSource.EndEdit();
tbSiteAdapter.Update(siteDataSet, "tbSiteInfo");
但保存不了,数据库里添加记录后,打开数据表,还是没变化,请问是我哪里做错了吗?