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()

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

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

'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

Edited 5 Years Ago by peter_budo: Adding code tags