Solved

LockOptimistic Issue?

Posted on 2004-08-20
5
852 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Exellent article...thanks for the link.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

771 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

10 Experts available now in Live!

Get 1:1 Help Now