修改了TextBox内的值后,为何Updata不回数据库?
如果去修改DataGridView则能更新回数据库,为什么绑定的TextBox修改后不能updata回数据库呢?
代码如下:
public partial class Form1 : Form
{
static string connString = @ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=persondatabase.mdb ";
string selectString = @ "select * from PersonTable ";
OleDbDataAdapter da;
DataSet ds;
OleDbConnection conn;
public Form1()
{
InitializeComponent();
conn = new OleDbConnection(connString);
//try
//{
// conn.Open();
//}
//catch (Exception e)
//{
// MessageBox.Show(e.ToString());
//}
da=new OleDbDataAdapter (selectString ,conn);
OleDbCommandBuilder cmb = new OleDbCommandBuilder(da);
ds = new DataSet();
da.Fill(ds, "PersonTable ");
dataGridView1.DataSource = ds.Tables [0] ;
textBox1.DataBindings.Add( "Text ", ds.Tables [0], "FirstName ");
}
private void button1_Click(object sender, EventArgs e)