Johnny6000
asked on
ASP DSN/DSN-less connection to SQL database
I have tried to make a DSN and a DSN-less connection to SQL databases both on my local machine and on my network. I *can* make a connection through Microsoft Query Analyzer to both databases through Windows authentication.
The ASP code is as follows:
1) For the DSN-less connection
<%
Dim objConn
Dim objRec
Dim strConnect
Set objConn = Server.CreateObject("ADODB .Connectio n")
Set objRec = Server.CreateObject("ADODB .Recordset ")
strConnect= "Driver=(SQLServer);Server =Remote;Da taBase=War ehouse;UID =myname;PW D=mypasswo rd;"
objConn.Open strConnect
objRec.Open "Select top 10* from myTable", objConn, 0,1,2
For the local machine substitute:
strConnect = "Driver=(SQL Server);Server=(local);Dat aBase=loca lDB;UID=my name;PWD=m ypassword; "
%>
2) For the DSN connection I connect the ODBC to the remote database, naming the DSN "Remote" and to the local database naming it "Local". Both Test connections succeed.
I use the following code:
<%
Dim objConn
Dim objRec
Dim strConnect
Set objConn = Server.CreateObject("ADODB .Connectio n")
Set objRec = Server.CreateObject("ADODB .Recordset ")
'For remote connection
objConn.Open "DSN=Remote"
'For local connection
objConn.Open "DSN=(local)"
%>
In all cases I get back the error message:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I know the data source is there, and I *did* mention the default driver.
What's going on? Why can't I make this connection?
John
The ASP code is as follows:
1) For the DSN-less connection
<%
Dim objConn
Dim objRec
Dim strConnect
Set objConn = Server.CreateObject("ADODB
Set objRec = Server.CreateObject("ADODB
strConnect= "Driver=(SQLServer);Server
objConn.Open strConnect
objRec.Open "Select top 10* from myTable", objConn, 0,1,2
For the local machine substitute:
strConnect = "Driver=(SQL Server);Server=(local);Dat
%>
2) For the DSN connection I connect the ODBC to the remote database, naming the DSN "Remote" and to the local database naming it "Local". Both Test connections succeed.
I use the following code:
<%
Dim objConn
Dim objRec
Dim strConnect
Set objConn = Server.CreateObject("ADODB
Set objRec = Server.CreateObject("ADODB
'For remote connection
objConn.Open "DSN=Remote"
'For local connection
objConn.Open "DSN=(local)"
%>
In all cases I get back the error message:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I know the data source is there, and I *did* mention the default driver.
What's going on? Why can't I make this connection?
John
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
These look promising but I have to put it on hold for a few days. John