Hello ...
I am a new member .. and a newbie ....
and I would like some one to help me please ...
how can I connect from vb 6.0 to access database by coding ... (not by using the Data Object (I mean the control)) ...
thank you very much ....
Printable View
Hello ...
I am a new member .. and a newbie ....
and I would like some one to help me please ...
how can I connect from vb 6.0 to access database by coding ... (not by using the Data Object (I mean the control)) ...
thank you very much ....
Right click on the your data control and select properties, then follow the simple on-screen instructions and you should be ok.
Hi Prototype,
I use ADO to connect to an Access 2002 database, here is the code I use
VB Code:
'String used to connect to the SRT database -- this allows for network use in the future 'Keep in module so that only module needs to be changed when database is moved Public cnSRTDB As String 'main SRT database Public SRT_DBcn As ADODB.Connection Public cmdSRT_DB As ADODB.Command Public Sub Open_SRTDB() 'set connection and open SRT database Set SRT_DBcn = New ADODB.Connection cnSRTDB = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\SRT_DB.mdb; Persist Security Info=False" SRT_DBcn.Open cnSRTDB End Sub Public Sub Close_SRTDB() 'close database and set to nothing If SRT_DBcn.State <> adStateClosed Then SRT_DBcn.Close Set SRT_DBcn = Nothing End If End Sub
I have this in a module and call the open and close when I need to. This allows me the flexibility to change the database connection from one place only -- we are planning on migrating to Oracle later.
Hope this helps!
Prototype,
Look here for a working example