Connecting to access database

ManicCW 0 Tallied Votes 168 Views Share

Code for connecting to Microsoft Access databse, opening and closing connection

Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Data.mdb;Persist Security Info=True"
cn.Open()
cn.Close()
dengbadeng 0 Newbie Poster

hello sir. i tried that code but it doesn't work. it says that it's not defined. what should i do?

kavithabhaskar 0 Junior Poster

did you add a header to it ? add 'imports system.data.oledb' as the header and try

pocohontus 0 Newbie Poster

which dbr u using-- access 2003 or 2007 ??
the code is for 2003
for 2007 use
"Provider=Microsoft.ACE.OLEDB.11.0;Data Source=|DataDirectory|Data.ACCdb;Persist Security Info=FALSE"

N A MSGBOX

uv4u 0 Light Poster

'firs import

imports system.data.oledb
Dim con As New OleDbConnection()
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=h:\MAINDB.mdb;"
con.open
statements
con.close
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.