?
Solved

ODBC in VBScript

Posted on 2001-07-18
8
Medium Priority
?
863 Views
Last Modified: 2006-11-17
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 ?
0
Comment
Question by:longlong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 20

Expert Comment

by:hes
ID: 6294186
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 6294188
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
 

Author Comment

by:longlong
ID: 6294342
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6294356
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
 
LVL 4

Expert Comment

by:VincentLawlor
ID: 6294426
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
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6294543
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
 

Author Comment

by:longlong
ID: 6307492
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
 
LVL 4

Accepted Solution

by:
VincentLawlor earned 1200 total points
ID: 6307613
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question