Need Help with Simple VB Questions
Posted on 2003-03-19
I am relativly new to VB. I have taken a beginner and intermediate class, however they were both a couple years ago. I am now writing a VB application to take test on the PC. This will be used for multiple users. I have a few basic questions that I forgot if are possible.
I have 3 forms with multiple subroutines on all of them. Almost all of these go out to an access database to retrieve data from the files. I use this code to open my connection in all of the subroutines:
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\Training Exams\Training.mdb;Mode=ReadWrite;Persist Security Info=False"
.CursorLocation = adUseClient
' get data from files here
Set cn = Nothing
Question 1) Can I just open the connection once in the General declarations and have it active for all 3 forms and will this speed up the performance of the application?
Question 2) In the connection string cuurently I have the MODE=READWRITE, but I had locking troubles so I had switched the mode to READ but this made it very slow. Why is the READWRITE option faster?
Thanks in Advance - Chad