I'm learning Databinding from here http://www.akadia.com/services/dotnet_databinding.html
I'm just updating the dataset and then updating the sql database using sqlDataAdaper.Update();
this.selectCommand = new SqlCommand();
this.selectCommand.CommandType = CommandType.Text;
this.selectCommand.Connection = this.connection;
this.dataAdapter = new SqlDataAdapter(this.selectCommand);
this.dataAdapter.MissingSchemaAction = System.Data.MissingSchemaAction.AddWithKey;
this.commandBuilder = new SqlCommandBuilder(this.dataAdapter);
this.selectCommand.CommandText = "Select `FirstName`,`lastname` from customers where customerId=123";
this.dataAdapter.Fill(this.dataSet, "customers");
now binding as:
// Simple Data Binding
txtBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.dataSet, "Customers.FirstName", true));
Its showing the firstname and when I change the first name and hit save button following code runs:
this.dataAdapter.Update(this.dataSet, "customers");
changed value is not reflected in the dataset and thus not in the database too. I don't understand why?
When will the BindingContext push the value that I changed in Textbox (GUI) into the dataset? Am I missing anything?