Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

db connection

Status
Not open for further replies.

bvahan5

Programmer
Jun 11, 2005
63
RU
i do use always this type of connection on LOCAL win server

strProvider="DSN=access_1"
set objConn = server.createobject("ADODB.Connection")
objConn.Open strProvider
Set rst = Server.CreateObject("ADODB.recordset")
strQuery="select ..."
rst.Open strQuery, strProvider

i start using REMOTE host (win)
where an another type of connection has been used

dsn_name = "access_1"
sDSNDir = Server.MapPath("/_dsn")
connectstr = "filedsn=" & sDSNDir & "\" & dsn_name
Set oConn = Server.CreateObject("ADODB.Connection")
qry = "SELECT ... "
Set oRS = oConn.Execute(qry)

i can't change a way i have to connect to DB on REMOTE host
i want to make identical the connections on both hosts, so it will be easy to share scripts, etc.

so i need to switch to a second type of connection on my LOCAL server

i don't know how to do that
where should "_dsn" folder be
how to create a "dsn_name" file

thanks for advices.

 
Perhaps you put the connection code into separate pages and then use #include to bring it into your scripts. This way you will be able to continue having different connections for different environments but only the single included file will be different between them.

That said, it is better to use an ADO "connection string" instead of a DSN. Take a look:
 
thanks for response

however the better way is to use one "standard" procedure, not 2 or 3, the last can mess all up requiring to remember which connection when to use and which to comment/uncomment

is a "_dsn" folder one that has to ne in what is the format of "dsn_name" files there?
is there any howto URL?
 
DSN is an acronym for Data Source Name. The format of the file will depend upon which ODBC driver is used. You can actually use the windows ODBC interface to help create and test a DSN file for your specific drvier/database combination.

Please be aware that most ASP applications do not use any DSN at all. ADO connection strings are the preferred way to connect. This becomes even more true in remote hosting situations.

 
i know
in my case the hoster is "famous" godaddy
many things are hidden there, so users have to follow their instructions
they do have 2 howto samples:
- dsnless
- with dsn

both do not work and i got tired to deal with their customer service
i managed to get to work a test with DSN
that's why i 'd like to switch to it on my local server as well

i use MS Access ODBC

in hoster's online mgmt system there is an interface to create a DSN
than it writes it somehow in a hidden from me folder "_dsn" (see above posts) and i refer to it in my script
i need to know how to make this dsn file - for another LOCAL server
 
Look for the ODBC Data Source Administrator program in your control panel administrative tools.

Since you are using MS Access, another way is to choose "Get External Data" from the file menu, then in the file explorer dialog box, choose ODBC Data Sources in the file-type dropdown listbox. This will show another dialog box that lists the existing DSNs on your local server and this dialog box also has a button labeled "New" that will allow you to create a new one. Watch closly that you actually create a "file" data source rather than a "machine" one.
 
may be i misunderstood you...
i did this
Admin Tools -> ODBC -> File DSN -> created dsn_name "access_1" with Access DB driver and stored it in folder by the name "access_1"

i do refer in my script to this dsn name

dsn_name = "access_1"
sDSNDir = Server.MapPath("/_dsn")
connectstr = "filedsn=" & sDSNDir & "\" & dsn_name
Set oConn = Server.CreateObject("ADODB.Connection")
qry = "SELECT ..."
oConn.Open connectstr

it returns an error on last line

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0xa90 Thread 0xaa8 DBC 0x2fe0064 Jet'.

what did i wrong?
any ides?
 
1) Are you storing that access file locally on the web server or are you tring to connect to one on another system?

2) Have you tried a DSNless connection to your database?
For example, if you had the database in you could use a conneciton string of:
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("/SomeFolder/mydata.mdb")

-T

barcode_1.gif
 
2 Tarwn
1. i am storing that access on LOCAL server
Remote server works fine
please read initial post
i have 2 servers
1 - LOCAL - full control, a connection is described in 1st post
2 - REMOTE - godaddy.com - partial control
have to use ANOTHER connection, described above
it uses a reference to /_dsn/dsn_name file i have no direct access to

i need to learn how to make this file and to switch on LOCAL server to the same connection to share scripts with "standard" connection

how to use this technics:
- create a _dsn folder (where?, permissions?)
- create a dsn_file (how? extension? permissions? anything in registry?)

thx for advices
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top