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.connec tion")
OBJrs1 = CreateObject("ADODB.record set")
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.connec tion")
OBJrs2 = CreateObject("ADODB.record set")
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
I open the same database 2 times!
but poiting to the same Record!
Jet 4.0 OLDB Provider
__________________________
objCmd1 = CreateObject("ADODB.connec
OBJrs1 = CreateObject("ADODB.record
objcmd1.ConnectionString="
objcmd1.mode=3
objcmd1.open()
OBJrs1.OPEN( "SELECT * FROM JC_MAIN WHERE NUMBOX > 70000" , OBJCMD1 , 2 , 3)
objCmd2 = CreateObject("ADODB.connec
OBJrs2 = CreateObject("ADODB.record
objcmd2.ConnectionString="
objcmd2.mode=3
objcmd2.open()
OBJrs2.OPEN( "SELECT * FROM JC_MAIN WHERE NUMBOX > 70000" , OBJCMD2 , 2 , 3)
__________________________
OBJRS1.FIELDS("CONTROLACD"
OBJRS1.UPDATE
*
OBJRS2.FIELDS("TOTOLDMSG")
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
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 >
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 >
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 :(
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hope for i helpong you today bye!