Connecting VB to Database

December 2016



Issue



I am unable to connect my VB code to access tables from ms access database.
Please help me to go through.

Solution


If you are using MS Access 97 then use ADODC connection..
  • Drag this from tool box
  • Right click and do the connection then test your connection.


If it is done then go to ur module code and write there code as:


Set cn = New Connection  
cn.ConnectionString = "provider=Microsoft.Jet.OLEDB.3.51;data source=" & App.Path & "name of database.mdb;"  
cn.Open  
n if using 2003 then  
Set cn = New Connection  
cn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=" & App.Path & "name of database .mdb;"  
cn.Open

Note


Thanks to prad for this tip on the forum.

Related :

This document entitled « Connecting VB to Database » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.