Click here to Skip to main content
15,887,596 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Variables Naming Pin
Dave Kreskowiak12-Feb-09 1:44
mveDave Kreskowiak12-Feb-09 1:44 
GeneralRe: Variables Naming Pin
Samir Ibrahim12-Feb-09 2:18
Samir Ibrahim12-Feb-09 2:18 
GeneralRe: Variables Naming Pin
Jon_Boy12-Feb-09 7:48
Jon_Boy12-Feb-09 7:48 
GeneralRe: Variables Naming Pin
Samir Ibrahim12-Feb-09 9:45
Samir Ibrahim12-Feb-09 9:45 
QuestionCrystal report problem Pin
mahalakshmi4211-Feb-09 19:54
mahalakshmi4211-Feb-09 19:54 
QuestionHow to apply Read lock to Record in VB 6.0 Pin
Jhanvy Thaker11-Feb-09 18:45
Jhanvy Thaker11-Feb-09 18:45 
AnswerRe: How to apply Read lock to Record in VB 6.0 Pin
Vimalsoft(Pty) Ltd11-Feb-09 22:47
professionalVimalsoft(Pty) Ltd11-Feb-09 22:47 
AnswerRe: How to apply Read lock to Record in VB 6.0 Pin
Prasadsm11-Feb-09 23:02
Prasadsm11-Feb-09 23:02 
The Lock Type



Imagine that, after creating a record set and working on it, you want to control who else can have access to the records of the set you are using. To exercise this control, you can create a "lock". This allows you, for example, to prevent other people from changing the records until you have finished with them. To support locking, the ADODB namespace is equipped with an enumeration named LockTypeEnum, which defines various options:

When a computer connects to a database, its user may need to make changes to various records at the same time, such as deleting a range of records or changing many records at the same time (such as giving a raise to many employees), instead of making one change, then another, then another. For this type of scenario, when the user accesses the records, instead of monopolizing them and waiting for the user to finish an operation that could take long, you can download the records on the user's computer, and disconnect the user from the database. The user would then make the necessary changes. When the user is ready to commit the changes, you can then reconnect to the data source and submit the changes. This type of lock is referred to as batch optimistic.
This lock is supported through the ADODB.LockTypeEnum.adLockBatchOptimistic value
You may have a database that a few different people access at the same time. If the database is small enough, which is the case for restricted environment, the likelihood of two people editing or updating the same record (at the same time) may be low. In this case, you can indicate that you want to lock the record only when necessary. In this case, you use what is referred to as optimistic locking.
This lock is implemented using the ADODB.LockTypeEnum.adLockOptimistic value
The above two options assume that you would lock many records to apply the indicated scenarios. If you prefer to lock one record at a time, you can use what is referred to as pessimistic locking.
This lock is done using the ADODB.LockTypeEnum.adLockPessimistic value
The above three scenarios allow a user to edit and/or update the records that are included in the set. In some cases, you may want to prevent any editing or update on the records while the set is being accessed. In this case, you can set the records to read-only.
This lock can be set using the ADODB.LockTypeEnum.adLockReadOnly value
If you don't want to specify the type of lock system to use on a record set, use the ADODB.LockTypeEnum.adLockUnspecified value, which is the default value. Otherwise, to specify the lock type, pass the desired value as the fourth argument to the RecordsetClass.Open() method. Here is an example:

Private Sub btnRecordset_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnRecordset.Click
Dim rstPeople As ADODB.RecordsetClass
Dim conADO As ADODB.ConnectionClass = New ADODB.ConnectionClass

rstPeople = New ADODB.Recordset
Dim fldEach As ADODB.Field

conADO.Open("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source='C:\Programs\People.mdb'", Nothing, Nothing, 0)
rstPeople.Open("Persons", _
conADO, _
ADODB.CursorTypeEnum.adOpenDynamic, _
ADODB.LockTypeEnum.adLockOptimistic)

rstPeople.Close()
End Sub
This uses the adLockOptimistic as the type of lock used on the recordset.
AnswerRe: How to apply Read lock to Record in VB 6.0 Pin
Dave Kreskowiak12-Feb-09 1:42
mveDave Kreskowiak12-Feb-09 1:42 
QuestionFilter percent (%) and apostrophes (') contained in a string Pin
mbv80011-Feb-09 16:54
mbv80011-Feb-09 16:54 
AnswerRe: Filter percent (%) and apostrophes (') contained in a string Pin
paas12-Feb-09 1:06
paas12-Feb-09 1:06 
AnswerRe: Filter percent (%) and apostrophes (') contained in a string Pin
Guffa12-Feb-09 1:33
Guffa12-Feb-09 1:33 
QuestionRubber Banding in VB 2008 Pin
StefanGeorgiev11-Feb-09 16:45
StefanGeorgiev11-Feb-09 16:45 
AnswerRe: Rubber Banding in VB 2008 Pin
Ranjit Viswakumar11-Feb-09 17:29
Ranjit Viswakumar11-Feb-09 17:29 
GeneralRe: Rubber Banding in VB 2008 Pin
Guffa12-Feb-09 1:41
Guffa12-Feb-09 1:41 
AnswerRe: Rubber Banding in VB 2008 Pin
Guffa12-Feb-09 1:39
Guffa12-Feb-09 1:39 
QuestionAdding web-address to menustrip and access from there. Pin
Gagan.2011-Feb-09 16:26
Gagan.2011-Feb-09 16:26 
AnswerRe: Adding web-address to menustrip and access from there. Pin
Dave Kreskowiak13-Feb-09 3:42
mveDave Kreskowiak13-Feb-09 3:42 
Questiongrouping subroutines Pin
Duane195811-Feb-09 15:58
Duane195811-Feb-09 15:58 
GeneralRe: grouping subroutines Pin
Luc Pattyn11-Feb-09 16:32
sitebuilderLuc Pattyn11-Feb-09 16:32 
GeneralRe: grouping subroutines Pin
Duane195811-Feb-09 16:55
Duane195811-Feb-09 16:55 
QuestionWorking with Active Directory in VB.NET Pin
sdavis8811-Feb-09 14:23
sdavis8811-Feb-09 14:23 
AnswerRe: Working with Active Directory in VB.NET Pin
Dave Kreskowiak13-Feb-09 3:43
mveDave Kreskowiak13-Feb-09 3:43 
QuestionInitialize array parameter? Pin
craigmg7811-Feb-09 10:56
craigmg7811-Feb-09 10:56 
AnswerRe: Initialize array parameter? Pin
Dave Kreskowiak11-Feb-09 14:11
mveDave Kreskowiak11-Feb-09 14:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.