AndiOliverI
12-16-2003, 10:43 PM
I made the following code which is supposed to make me connection to my database with different lockings:
Public cnnTemp As New ADODB.Connection
Public cmdTemp As New ADODB.Command
Public RecTmp As New ADODB.Recordset
If cnnTemp.State = adStateOpen Then cnnTemp.Close: DoEvents
If RecTmp.State = adStateOpen Then RecTmp.Close: DoEvents
If Conf = True Then
cnnTemp.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathDb & MyDataBase & ";Persist Security Info=False"
Else
cnnTemp.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathDb & SocAleasa & "\" & MyDataBase & ";Persist Security Info=False"
End If
Set cnnTemp.ConnectionTimeout = 30
cnnTemp.Open
Set cmdTemp.ActiveConnection = cnnTemp
cmdTemp.CommandText = MySql
If MyOpenMode = "read" Then RecTmp.LockType = adLockReadOnly
If MyOpenMode = "write" Then RecTmp.LockType = adLockBatchOptimistic
Set RecTmp = cmdTemp.Execute
The code is working well but it doesn't allow me to update or addnew. Checking the code has return me than myopenmode returns corec read or write and supposed to be readonly or optimistic, but somehow is not working, any help?
Public cnnTemp As New ADODB.Connection
Public cmdTemp As New ADODB.Command
Public RecTmp As New ADODB.Recordset
If cnnTemp.State = adStateOpen Then cnnTemp.Close: DoEvents
If RecTmp.State = adStateOpen Then RecTmp.Close: DoEvents
If Conf = True Then
cnnTemp.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathDb & MyDataBase & ";Persist Security Info=False"
Else
cnnTemp.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & PathDb & SocAleasa & "\" & MyDataBase & ";Persist Security Info=False"
End If
Set cnnTemp.ConnectionTimeout = 30
cnnTemp.Open
Set cmdTemp.ActiveConnection = cnnTemp
cmdTemp.CommandText = MySql
If MyOpenMode = "read" Then RecTmp.LockType = adLockReadOnly
If MyOpenMode = "write" Then RecTmp.LockType = adLockBatchOptimistic
Set RecTmp = cmdTemp.Execute
The code is working well but it doesn't allow me to update or addnew. Checking the code has return me than myopenmode returns corec read or write and supposed to be readonly or optimistic, but somehow is not working, any help?