Connecting VB to Database

April 2017



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


Published by aakai1056. Latest update on May 25, 2010 at 12:35 PM by aakai1056.
This document, titled "Connecting VB to Database," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).