Updating a DataAdapter, DataGrid after changing the database

B

Boris Zakharin

I currently have a page which displays data in a DataGrid from a DataSet
filled by an OleDbDataAdapter. It also has buttons to carry out events which
should cause the grid contents to change (either a row is deleted or it is
changed so that the criteria of the select query no longer apply). However,
the grid does not change unless I explicitly reload the page using
Response.Redirect(Request.Url.AbsoluteUri) and I'm sure that could cause
unwanted side effects.

The current code is as follows:

oleDbConnection1.Open();
OleDbCommand cmdApp = new OleDbCommand("DELETE FROM jobs WHERE job_id =
?", oleDbConnection1);
cmdApp.Parameters.Add("job_id",
int.Parse(DataGrid1.DataKeys[e.Item.ItemIndex].ToString()));
cmdApp.ExecuteNonQuery();
oleDbConnection1.Close();
oleDbDataAdapter1.Fill(dsJobs21);
DataGrid1.DataBind();

Can anyone tell me what I'm doing wrong here?

Thanks,
Boris Zakharin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top