I am updating the dataset row with new data from textboxes, then trying to update it to my database. I keep getting this error:
Update requires a valid UpdateCommand when passed DataRow collection with modified rows.
How can I fix this error?
Here's my code:
protected void Save_Butt_Click( object sender, EventArgs e ) {
OleDbConnection connect = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|/PizzaOrders.mdb;Persist Security Info=True" );
//set up connection string
OleDbCommand command = new OleDbCommand("SELECT [title], [gname], [sname], [address], [suburb], [postcode], [dayphone], [email] FROM [users] WHERE ([username] = @username)", connect);
OleDbParameter param0 = new OleDbParameter("@username", OleDbType.VarChar);
param0.Value = HttpContext.Current.User.Identity.Name;
command.Parameters.Add(param0);
connect.Open();
OleDbDataAdapter da = new OleDbDataAdapter(command);
DataSet dset = new DataSet();
da.Fill(dset);
dset.Tables[0].Rows[0]["title"] = Title_DDL.Text;
dset.Tables[0].Rows[0]["gname"] = Fname_txt.Text;
dset.Tables[0].Rows[0]["sname"] = LN_txt.Text;
dset.Tables[0].Rows[0]["address"] = Address_txt.Text;
dset.Tables[0].Rows[0]["suburb"] = suburb_txt.Text;
dset.Tables[0].Rows[0]["postcode"] = Postcode_txt.Text;
dset.Tables[0].Rows[0]["dayphone"] = Phone_txt.Text;
dset.Tables[0].Rows[0]["email"] = Email_txt.Text;
da.Update(dset);
}