I have a very small, simple database in Access. I have it bound to a
DataGridView in VB.NET. I can add, change and delete records via the
DataGridView, and the changes are reflected in Access. A different section
of
code (aka Checking Code) reads the database and under certain conditions
it
will change a field in the database. I thought everything was working
pretty
well, until I realized that changes made via the DataGridView weren't
being
detected by the Checking Code.
Since this is a simple database, I opted to use a ADO.NET RecordSet:
cnAlerts = New ADODB.Connection
cnAlerts.Open(connStr)
rsAlerts = New ADODB.Recordset
rsAlerts.CursorLocation = CursorLocationEnum.adUseServer
rsAlerts.ActiveConnection = cnAlerts
rsAlerts.Open("SELECT * FROM Alert ORDER BY Symbol", cnAlerts,
CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic)
Before I added the CursorLocation, the .BOF and .EOF were False when the
database was empty?!? UseServer seemed to fix that problem. I've tried
different CursorTypes to no avail. The Checking Code is:
If rsAlerts.BOF And rsAlerts.EOF Then ' no alerts
Exit Sub
Else
rsAlerts.MoveFirst()
End If
For i = 5 To aUBound
Do While rsAlerts.Fields.Item(SYMBOL_COL).Value <= Symbols(i)
If rsAlerts.Fields.Item(SYMBOL_COL).Value = Symbols(i) Then
Select Case rsAlerts.Fields.Item(OPERATOR_COL).Value
Case "increases to"
.. . .
Case "decreases to"
.. . .
End Select
rsAlerts.MoveNext()
If rsAlerts.EOF Then Exit For
End If
Loop
Next i
The Checking Code runs about every 10 seconds, and the data in the
DataGridView / Access database may change at any time. Why isn't the
Checking
Code "seeing" the changes made to the database??? BTW, this is all in the
same thread. And I only have one copy of the database on my C: drive. And
I'm
not using AcceptChanges in my program. Thanks...


|