Solved

LockOptimistic Issue?

Posted on 2004-08-20
5
860 Views
Last Modified: 2012-06-21
1. If one routine is looking at the record  will the LockOptimistic prevent it from accessing it and visa versa?

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=DBDSN;UID=System;PWD=xxxxx;DATABASE=DBName"
objRecordset.CursorLocation = adUseClient

errMessage = "Died opening Recordset"

objRecordset.Open "SELECT * FROM tblFirewall WHERE tblFirewall.FirewallIP Like '" & FirewallIP & "'", objConnection, adOpenStatic, adLockOptimistic
    If objRecordset.BOF Then
    Else
        strFirewallPW = objRecordset("FirewallPW")
            FirewallPW = strFirewallPW
        strFirewallEN = objRecordset("FirewallEN")
            FirewallEN = strFirewallEN
        strFirewallSSH = objRecordset("FirewallSSH")
            FirewallSSH = strFirewallSSH
       
  End If
       
        objRecordset.Close
        objConnection.Close
0
Comment
Question by:brian_appliedcpu
  • 3
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
kumvjuec earned 250 total points
ID: 11858293
It locks only when update is called. Since you are only using select above, it will not lock.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdcstlocktypeenum.asp
0
 
LVL 2

Author Comment

by:brian_appliedcpu
ID: 11858815
So do I even need to use the lock when I don't plan on updating the record?
Or in this case should I use adLockReadOnly?
0
 
LVL 2

Author Comment

by:brian_appliedcpu
ID: 11858970
PS..

do I need the lock with the
sql = "insert into tblError...

What is the rule of thumb?  to always use it?
0
 
LVL 3

Expert Comment

by:kumvjuec
ID: 11859771
Read it here and use based on what your exact need is :)
http://www.tek-tips.com/faqs.cfm?fid=618
0
 
LVL 2

Author Comment

by:brian_appliedcpu
ID: 11862230
Exellent article...thanks for the link.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

713 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