Database Connection
Hi All
I am trying to connect to database and following method works fine,
With theatorDB
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "User ID=Admin;Password=;" & _
"Data Source=C:project/new/theator.mdb;"
.Open
End With
But I want to Use variable for database path like
path = project/new/theator.mdb
and want to put source = path
but I tried and doesn't work. Would anyone can help me.
Thanks in advance
Kethees
[552 byte] By [
Kethees S] at [2007-11-15 17:38:05]

# 1 Re: Database Connection
This is an easy one
Dim PathToFile as string
PathToFile = "C:\project\new\theator.mdb"
With theatorDB
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "User ID=Admin;Password=;Data Source=" & PathToFile & ";"
.Open
End With
Tom Cannaerts
slisse@planetinternet.be
Moderator on http://www.vbcodelibrary.co.uk/board
A bottomless pit, I'm sure it came with the place, who would dig one on purpose?
Cakkie at 2007-11-10 0:43:53 >

# 2 Re: Database Connection
Dim strPath as String
strPath = "C:\project\new\theator.mdb"
With theatorDB
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "User ID=Admin;Password=;" & _
"Data Source=" & strPath
.Open
End With
David Paulson
# 3 Re: Database Connection
the easy one:
Dim strPath as String
strPath = "C:\project\new\theator.mdb"
theatorConn="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & strPath
treatorDB.open theatorConn
# 4 Re: Database Connection
Hmm, do note that on your way, you are making use of ODBC rather than OLEDB, so the difference is rather big.
Tom Cannaerts
slisse@planetinternet.be.remove.this.bit
Moderator on http://www.vbcodelibrary.co.uk/board
A bottomless pit, I'm sure it came with the place, who would dig one on purpose?
Cakkie at 2007-11-10 0:47:02 >
