Solved

Using ADO problem

Posted on 2002-04-30
9
177 Views
Last Modified: 2010-05-02
I use ADO to do database manipulation(DB access2000). First I open the connection, then import records to "mytable" from a text file. Then I CLOSE this recordset. Try to query "my table" using "select * from my table". But sometimes, I got "rst.eof" is true, some times is false. The result is not consistant. I opened the table, the records are there. I am wondering if the database status is not refreshed after I import records from text file? How should I refresh it? The wierd thing is if I use "debug" to step into every process without changing code, the "rst.eof" will always "false"???

Any help will be appreicated!

Thanks!

Lucy
0
Comment
Question by:llucy88
9 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 6981198
can you post some code please?
0
 

Expert Comment

by:HobbitHouse
ID: 6981259
try this after the import and before the query:

mytable.MoveFirst

0
 
LVL 3

Expert Comment

by:cmgarnett
ID: 6981335
Try using BeginTrans and CommitTrans on your ADO record writing code.

Sometimes ADO seems to lag behind and using the BeginTrans and CommitTrans makes the program wait for the ADO processing to be completed.
0
 
LVL 1

Expert Comment

by:S2
ID: 6981426
Are you closing the connection between the import and the opening of the record set, if you are that might be the problem.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:magoo2
ID: 6981436
Also try adding DoEvents after closing your original recordset.
0
 

Author Comment

by:llucy88
ID: 6981532
Too much code for me to put here.

my table.movefirst, doevents, not working.


As files importing tables are for multiple tables. I am using the "begintrans" here to utilize the "rollback" feature in case one of the file format is not right. I defined differenct DB connections for "importing" and "manipulation". Between them, I closed the importing connection. Maybe the reason is  S2's comments. I just don't understand why? Do I have to change them same connection? why sometimes the process is right?

Thanks!

Lucy
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6981534
this sample should work for you
(the source for the problem is the same)
you can find some code to flush changes to the database from client pc.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q240317

cn.Properties("Jet OLEDB:Transaction Commit Mode") = 1

SUMMARY
Because the Microsoft Jet database engine has a read cache and lazy writes, you can get duplicate values in your custom counter field if two applications add records in less time than it takes for the cache to refresh and the lazy-write mechanism to flush to disk. This article presents a method that takes these factors into account.



0
 

Accepted Solution

by:
BBaron earned 100 total points
ID: 6982989
Hi,
just a little comment....
I had the exact same problem about a year ago when I was
importing from anouther database, using update querys. If I put a pause of say 1 sec before the requery it would be ok, if not then on the update I got duplicate error.
I fixed the problem by closing and reopening the connection to the target database. This obviously decreased efficiency drastically but seemed to work. Still dont know how to fix properly though. Glad to see some other poor fool has the same stupid problems as me ;-))

0
 

Author Comment

by:llucy88
ID: 6983271
Thanks a lot!

fool
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now