Search code examples
vb6

How to connect to Database app path - vb6


Im trying to connect my databases(not binded/flexible) and it will run when the form activated. But in my code it kept error and didn't connected to the database. This is my last code:

Private Sub LoginForm_Activate()
    Aadodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database\Login.mdb;Persist Security Info=False"
    Aadodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database\login.mdb;Persist Security Info=False"
End Sub

I have ever connected it through the adodc property. But after i run it it broke if i move the folder to another folder so i tried to connect it using a flexible connectionstring.


Solution

  • I have found it out, the adodc should be refreshed Aadodc1.Refresh and the record source Aadodc1.RecordSource = "Select * from [table name]" must be defined. That's all :)