ODBC in VBScript

My database(MS Access) reside on a different PC,
I can't establish the connection my PC and the PC which has my database.

I already used the ODBC with the "data source system"

Set strConn = Server.CreateObject ("ADODB.Connection")
strnConn.Open "data source=dsntestdb;user id=Admin;pwd=my_password"

But if the data source (dsntestdb) points to the MS Access file on the same PC, this code is very good.

I'd like to know how can we give the user id and password for connecting to the distant PC ?

Is my code is good ?
longlongAsked:
Who is Participating?
 
VincentLawlorCommented:
The password supplied to the connectio string is the password for the database.

As I said in an earlier post you will need access to the machine on which the Access database resides.

* Go to the machine on which it resides and share the folder. You will then be able to access the database from another machine.
Then:
* Map a network drive from the machine that needs to access the database. You will be asked for a username and password (Network username and password). Setup your ODBC connection as normal.
Or:
* In ODBC when you are selecting the database click the network button select the network share where the database resides (ODBC will map the drive for you). Enter the username and password (Network username and password).

If the database is password protected then in ODBC select Advanced settings and enter the username and password (Database username and password).

Hope this clears is tup for you.

Vin.

 
0
 
hesCommented:
In the control panel go into ODBC data sources 32bit
and create a system DSN pointing to the remote database

then for your "data source"= use the name of the system dsn you created
0
 
TimCotteeHead of Software ServicesCommented:
When you say distant, how distant. If it is on a lan, you should be able to specify the UNC path to the database:

\\ServerName\ShareName\FolderName\DatabaseName.mdb in the dsn definition.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
longlongAuthor Commented:
But I have to use the system data source or the file data source ? What is the difference ?
I used the system data source but it appeared the error message, you don't have the autorisation for accessing.
0
 
VincentLawlorCommented:
This can be done by selecting a database on the network

Just click on the network button and select the Machine,  folder and database required.
0
 
VincentLawlorCommented:
BTW through ODBC you cannot use an UNC path to the file.

ODBC will map a drive for you.

You also must have asscess to the in which folder the database resides.

Go to the Machine and open explorer right click on the folder select sharing, Share As Name of folder.

Alternatively you could use a DSNless connection.

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;data source=\\Test\Temp\Anydb.mdb;user id=Admin;pwd=my_password"

This will work with an UNC and without the need for a DSN.

The Data Source= bit should be the UNC path to your database on the network.

Vin.

0
 
Dave_GreeneCommented:
I wouldn't recommend using a DSN-Less connection in VBScript... it would expose your UID and PWD to everyone.

conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;data source=\\Test\Temp\Anydb.mdb;user id=Admin;pwd=my_password"

If you build your DSN and hit the advanced button you can build the DSN with a User Id and password!
0
 
longlongAuthor Commented:
I'd like to know the password which we gave, this is the password for network (login to another PC on the network) or this is the file's password (password for open this file).

If I want to give the password for login to another PC bacause my database (Aceess) is on another PC, how can I do it ?
Thank.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.