borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How to make two databases link)Next Topic (Help on SQL???) New Topic New Poll Post Reply
AndreaVB Forum : Database : Open/Close/Lock Access DBase
Poster Message
Shady
Level: VB Guru


Registered: 08-07-2002
Posts: 305

icon Open/Close/Lock Access DBase

Hello once again

A couple of quick questions:-

I have a small network accessing a single access database through a VB application, if I tell the program to close the database when it is exited will that shut off all the individual connections to the database or will it just close that  specific connection.

Also, when a user is editing a record is it possible to lock all other users out of the record whilst a user edits the record.

Any suggestions greatly appreciated

Regards

Shady

____________________________
I don't wanna die... but I ain't keen on livin' either

10-10-2002 at 03:35 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Open/Close/Lock Access DBase

Closing the database (via VB program) will only terminate that connection.

When you open a recordset (table) for editing, there's different options for locking the records (from the help files:)

adLockPessimistic
Pessimistic locking, record by record—the provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately upon editing.

adLockOptimistic
Optimistic locking, record by record—the provider uses optimistic locking, locking records only when you call the Update method.

adLockBatchOptimistic
Optimistic batch updates—required for batch update mode as opposed to immediate update mode.


[Edited by JLRodgers on 10-10-2002 at 09:49 AM GMT]

10-10-2002 at 03:47 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: Open/Close/Lock Access DBase

Maybe this won't match your probs, but I just give this hint to mind about.
In Access VBA are avaliable the BeginTrans, CommitTrans and Rollback methods, to manage a transaction. You can start a transaction if you want to avoid that several users make changes to a certain record at the same time, as this could generate a data-error. Also a transaction can protect data if the connection have an unexpected breakdown before finish the record editing process.
Example: you go to your bank to put some money, and there are four steps: you give the money to the cash employee, he prints the receipt, the program records the operation and finally updates the amount in your account. Now, imagine a power breakdown between the third and the fourth passage! A transaction blocks the database (BeginTrans), make all the changes and, when finished with no errors, saves the changes in the record (CommitTrans), and finally releases the database for other users.
You can study about transactions. I recently knew that SQL has BeginTrans, CommitTrans and Rollback, too.
Hope it helps.

____________________________
Real Programmer can count up to 1024 on his fingers

11-10-2002 at 12:17 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : Open/Close/Lock Access DBase
Previous Topic (How to make two databases link)Next Topic (Help on SQL???) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder