Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > ADO Data > VB.NET ADO Reco...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 4205 of 4320
Post > Topic >>

VB.NET ADO Recordset DataGridView and Access not in sync w/other c

by =?Utf-8?B?SmltIENyaXN0?= <JimCrist@[EMAIL PROTECTED] > Apr 9, 2008 at 05:49 PM

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...
 




 3 Posts in Topic:
VB.NET ADO Recordset DataGridView and Access not in sync w/other
=?Utf-8?B?SmltIENyaXN0?=   2008-04-09 17:49:00 
Re: VB.NET ADO Recordset DataGridView and Access not in sync w/o
"Bob Barrows [MVP]&q  2008-04-10 07:07:06 
Re: VB.NET ADO Recordset DataGridView and Access not in sync w/o
=?Utf-8?B?SmltIENyaXN0?=   2008-04-10 06:14:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 15:10:27 CST 2008.