I have an application with multiple SqlCeResultSets, and a combobox and a datagrid on one form. I have setup the ResultSets to return subsets of the same SQL CE table, using statements like:
"SELECT * FROM DLH WHERE STATUS = 'A'"
"SELECT * FROM DLH WHERE STATUS = 'D'"
"SELECT * FROM DLH"
Which return ResultSets named DLH_A, DLH_D and DLH respectively. The ResultSets are setup with
(ResultSetOptions.Scrollable Or ResultSetOptions.Sensitive _
Or ResultSetOptions.Updatable)
When I change the selection in the combobox, the datasource of the grid changes to the corresponding ResultSet with the code:
Dim StatusCode As String = DirectCast(cboList.SelectedItem, Item).sValue
If StatusCode = "T" Then
DLH.Bind(DLHResultSetBindingSource)
End If
If StatusCode = "A" Then
DLHResultSetBindingSource.DataSource = DLH_A.ResultSetView
End If
If StatusCode = "D" Then
DLHResultSetBindingSource.DataSource = DLH_D.ResultSetView
End If
In a second form I am inserting data into the base table using the DLH ResultSet. Then I change the value of STATUS column in a few rows in the database. This should make them disappear from one ResultSet and appear in another. For example, if I take a row with STATUS = 'A' and change it to 'D', it should disappear from DLH_A and appear in DLH_D.
If I already have some data in the SQL CE database, the ResultSets show the changes properly. However, if the SQL CE database is empty to begin with, the ResultSets do not show the changes. The rows appear in their original ResultSet. I know the data is successfully inserted into the SQL CE database, because if I close the application and restart it, it all works fine.
I have tried Disposing the ResultSets and recreating them in several ways, but I cannot get the ResultSets to work if I start with an empty database. I cannot figure out why.