I have these in my module:
Code:
Public con As New ADODB.Connection
Public rs1 As New ADODB.Recordset
Public Sub opendb()
Dim connect As String
connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\..\Documents\tracking system\tracking.mdb;Persist Security Info=False"
With con
.Open connect
.CursorLocation = adUseClient
End With
End Sub
and in my log in form:
Code:
Set rs1 = con.Execute("Select * from useraccounts Where uname like '" & txtUserName & "' " & _
" And upassword Like '" & txtPassword & "'")
If (rs1.RecordCount > 0) Then
..
Else
...
End If
End Sub
These are my old codes way back 2011 also using vb6 but my database was MySQL. Now I am using MS Access hence the jetoledb in provider. It gives me error saying "operation is not allowed when object is closed"
I tried adding these:
Dim con As New ADODB.Connection
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.ConnectionString = "Data Source=" & App.Path & "\tracking.mdb"
con.Open
with these, I can run the program without errors. But wouldn't it add conflict to the codes in module?
Thanks
PS: is it normal for my .mdb located in vb6 dir (v98) to become readonly?