• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 902
  • Last Modified:

LockOptimistic Issue?

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
brian_appliedcpu
Asked:
brian_appliedcpu
  • 3
  • 2
1 Solution
 
kumvjuecCommented:
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
 
brian_appliedcpuAuthor Commented:
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
 
brian_appliedcpuAuthor Commented:
PS..

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

What is the rule of thumb?  to always use it?
0
 
kumvjuecCommented:
Read it here and use based on what your exact need is :)
http://www.tek-tips.com/faqs.cfm?fid=618
0
 
brian_appliedcpuAuthor Commented:
Exellent article...thanks for the link.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now