ado.net not retrieving updated records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an asp.net application which allows users to search, create and update records in a SQLServer2000 DB. Search results are displayed in a datagrid
The problem is after a record is updated or created and the datagrid refreshed by the user, the newly updated record doesn't display in the search results. The datagrid itself is definately refreshing as the record that has been updated disappears completely
If I close and open the browser and do a new search the record appears
Any db connections I open I have closed in a finally block and the dataset I use to populate the datagrid is NOT held in session
Any ideas?
 
Can you post the code that fires after the update? If you're sure the
update is working this should be all that's necessary.

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
shmeian said:
I have an asp.net application which allows users to search, create and
update records in a SQLServer2000 DB. Search results are displayed in a
datagrid.
The problem is after a record is updated or created and the datagrid
refreshed by the user, the newly updated record doesn't display in the
search results. The datagrid itself is definately refreshing as the record
that has been updated disappears completely.
If I close and open the browser and do a new search the record appears.
Any db connections I open I have closed in a finally block and the dataset
I use to populate the datagrid is NOT held in session.
 
Thanks for the reply. I've actually found the problem. It's something to do with DataViews as I use one to filter results by date. Sorry I forgot to mention this.
Is there a way I can make sure the dataview is refreshing when the function is called
Here's the code anyway

SqlConnection sqlSelectConn = new SqlConnection(connString)
tr
{
//Query the database via Microsoft Data Access Application Block SqlHelper
DataSet ds = SqlHelper.ExecuteDataset(sqlSelectConn,CommandType.StoredProcedure, storedProcName, new SqlParameter("@searchcriteria", streetName));
//Filter the dataset
DataView filteredView=new DataView(ds.Tables[storedProcName])
//filter is a select string which is set previousl
filteredView.RowFilter=filter

return ds

finall

sqlSelectConn.Close()
}
 
I've fixed the problem by calling the BeginInit() method of the DataView before filtering. I'm not exactly sure what this does but it works!
 
Back
Top