|
-
May 29th, 2006, 07:23 AM
#1
dsn less connection to Access Database
hi,
i m using vb6.0 as front end & database as access. i want to create connection
ADO,it should be dsn less. but i want to use this s/w in LAN. if i use with dsn then i ve create dsn on each machine. instead of that i will create dsn less connection. can anyone tell me what i should write in connection string. if i give hard coded path like d:/abc.mdb then machine on which this .mdb file will present there it will work, but if i installed on another pc it will not work. Basically i want to create s/w which will work in LAN. pls tell me how to write connection code.
-
May 29th, 2006, 07:34 AM
#2
Re: dsn less connection to Access Database
If you are actually looking for a multi-user application then I would suggest that you use SQL Server or MSDE (free download from Microsoft). If you want a DSN less connection then you will have to either hard-code the path & name of the database in the code or else save it in a file and then read it everytime you need to connect to the database from the application. A DSN less connectionstring would look like this
Code:
connectionString = "Provider=Microsoft.Jet.OleDB.4.0; Data Source = " & databasepath&name
Now remember if the database is residing in a folder that is shared on the server then you will have to use the complete UNC path like \\ServerName\ShareName\DatabaseName.
-
May 29th, 2006, 07:51 AM
#3
Re: dsn less connection to Access Database
thanx Shuja Ali,
as application is very small that's why i m using Access as database. as u suggest storing path in file. can i create one .ini file & store the path inside that file. suppose my server machine name is "minfo" & another machine is "mac1" where i m installing this s/w.
just tell me this is the way i ve to give path.
databasepath="\\minfo\d\"
connectionString = "Provider=Microsoft.Jet.OleDB.4.0; Data Source = " & databasepath&abc.mdb
this is correct way of giving path.
-
May 29th, 2006, 07:55 AM
#4
Re: dsn less connection to Access Database
You are almost right except that there should be a space between databasepath and he database name and the database name shouldbe in quotes, like this
Code:
databasepath="\\minfo\d\"
connectionString = "Provider=Microsoft.Jet.OleDB.4.0; Data Source = " & databasepath & "abc.mdb"
-
May 29th, 2006, 08:05 AM
#5
Re: dsn less connection to Access Database
thanx Shuja for helping me.
it was my typing mistake. but thanx a lot
-
May 29th, 2006, 08:08 AM
#6
Re: dsn less connection to Access Database
You are always welcome.
-
May 29th, 2006, 07:12 PM
#7
Re: dsn less connection to Access Database
Just for set it clear
1.- DSNless connection (ODBC)-->
"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\MYDB\TEST.MDB"
2.- Native OLEDB Access provider --->
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\MYDB\TEST.MDB"
Number 2 should perform a little better than 1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|