Link to home
Start Free TrialLog in
Avatar of Pemtium
Pemtium

asked on

ADO error Locking or Delay During Update

I'm Using Foxpro 7.0

I open the same database 2 times!
but poiting to the same Record!

Jet 4.0 OLDB Provider

______________________________________________________________________________
objCmd1 = CreateObject("ADODB.connection")
OBJrs1  = CreateObject("ADODB.recordset")

objcmd1.ConnectionString="file name=data\DATA01.udl"
objcmd1.mode=3
objcmd1.open()
OBJrs1.OPEN( "SELECT * FROM JC_MAIN WHERE NUMBOX > 70000" , OBJCMD1 , 2 , 3)


objCmd2 = CreateObject("ADODB.connection")
OBJrs2  = CreateObject("ADODB.recordset")

objcmd2.ConnectionString="file name=data\DATA01.udl"
objcmd2.mode=3
objcmd2.open()
OBJrs2.OPEN( "SELECT * FROM JC_MAIN WHERE NUMBOX > 70000" , OBJCMD2 , 2 , 3)
_________________________________________________________________________________



   OBJRS1.FIELDS("CONTROLACD") = OBJRS1.FIELDS("CONTROLACD").VALUE + 1
   OBJRS1.UPDATE

*

   OBJRS2.FIELDS("TOTOLDMSG") = OBJRS2.FIELDS("TOTOLDMSG").VALUE + 1
   OBJRS2.UPDATE

(same records)

on the 2nd Update i got and error:
The Microsoft database engine stopped the process cause you and another user are trying to change the same
data at the same time.  (WHY?)

by the way, i dont care if the 2nd overwrite the data that the previous update did! i just wnat to avoid
the error. If there a way to know in advanced if the record is locked  or in a Update Process

Another Note: if i Insert a timeout beetween each update of like 5 seconds i dont get any error

Avatar of Darrel_Fong
Darrel_Fong

check make sure system not own file on permission otherwise pretend error not happening or also i am writing books for this and you can have a copy ok?

hope for i helpong you today bye!
Darrel.....you still make no sense....
Hi,
The problem seems to be in your locking modes.

Instead of 3 [Const adModeReadWrite = 3], try the least restricting mode [like Const adModeShareDenyNone = &H10].
Similarly, try a less restricting cursor type [Instead of Const adOpenDynamic = 2, try Const adOpenStatic = 3], and a less restricting locking if possible.
Also, its a good practice to use the constant Enum names instead of the numbers.

Hope this helps.

< ReallyVirtual >
Avatar of Pemtium

ASKER

Constant number:
Ya i always try to use Constant Define Var, that was a quick Part of Program to test!
but i still have error doing those change.

Look Like ADO is Updating my FIle with Delay or something, like i explain whne i add
a Delay for about 5sec bettwen both update, i dont get any error.  :(

look like i  will have to use ON ERROR, and i really dont like to Code that way

Thank for the try :(

No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

walterecook
EE Cleanup Volunteer
agreed
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial