468,120 Members | 1,919 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,120 developers. It's quick & easy.

Unable to connect to DSN

I have a page that is trying to connect to my SQL Database. All the
code I have seen shows me to connect the same way. The error I am
getting says:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/connectDB.asp, line 13
Now I know the DSN is there, because my VB program uses it on the same
machine. I copied the Open string directly from the VB program. This
is the same format I find in all my other examples. None have any
default drivers specified.

Here is the HTML file:
************************************************** *******************
<html>
<head>
<title>ABC Corporation</title>
</head>
<body>

<h2>ABC Corporation Employee Extensions</h2>
<p>

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "DSN=Customer;" & _
"UID=sa;PWD="

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

</body>
</html>
************************************************** *******************

What am I missing?

Thanks,

Tom.

Jul 19 '05 #1
7 1946
Try the following;

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "Customer", "sa", ""

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Thomas Scheiderich <tf*@deltanet.com> wrote in message
news:40************@deltanet.com...
I have a page that is trying to connect to my SQL Database. All the
code I have seen shows me to connect the same way. The error I am
getting says:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/connectDB.asp, line 13
Now I know the DSN is there, because my VB program uses it on the same
machine. I copied the Open string directly from the VB program. This
is the same format I find in all my other examples. None have any
default drivers specified.

Here is the HTML file:
************************************************** *******************
<html>
<head>
<title>ABC Corporation</title>
</head>
<body>

<h2>ABC Corporation Employee Extensions</h2>
<p>

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "DSN=Customer;" & _
"UID=sa;PWD="

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

</body>
</html>
************************************************** *******************

What am I missing?

Thanks,

Tom.

Jul 19 '05 #2
Steven Burn wrote:
Try the following;

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "Customer", "sa", ""

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>
No, same error. I am running on W2k. Do I need to do something special
with the Web Server to handle ODBC?

Tom.
--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Thomas Scheiderich <tf*@deltanet.com> wrote in message
news:40************@deltanet.com...
I have a page that is trying to connect to my SQL Database. All the
code I have seen shows me to connect the same way. The error I am
getting says:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/connectDB.asp, line 13
Now I know the DSN is there, because my VB program uses it on the same
machine. I copied the Open string directly from the VB program. This
is the same format I find in all my other examples. None have any
default drivers specified.

Here is the HTML file:
************************************************ *********************
<html>
<head>
<title>ABC Corporation</title>
</head>
<body>

<h2>ABC Corporation Employee Extensions</h2>
<p>

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "DSN=Customer;" & _
"UID=sa;PWD="

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

</body>
</html>
************************************************ *********************

What am I missing?

Thanks,

Tom.



Jul 19 '05 #3
How does it work if the connection is literal instead of via a DSN?

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Thomas Scheiderich <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
Steven Burn wrote:
Try the following;

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "Customer", "sa", ""

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

No, same error. I am running on W2k. Do I need to do something special
with the Web Server to handle ODBC?

Tom.
--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Thomas Scheiderich <tf*@deltanet.com> wrote in message
news:40************@deltanet.com...
I have a page that is trying to connect to my SQL Database. All the
code I have seen shows me to connect the same way. The error I am
getting says:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/connectDB.asp, line 13
Now I know the DSN is there, because my VB program uses it on the same
machine. I copied the Open string directly from the VB program. This
is the same format I find in all my other examples. None have any
default drivers specified.

Here is the HTML file:
************************************************ *********************
<html>
<head>
<title>ABC Corporation</title>
</head>
<body>

<h2>ABC Corporation Employee Extensions</h2>
<p>

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "DSN=Customer;" & _
"UID=sa;PWD="

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

</body>
</html>
************************************************ *********************

What am I missing?

Thanks,

Tom.


Jul 19 '05 #4
Thomas Scheiderich wrote:

No, same error. I am running on W2k. Do I need to do something
special with the Web Server to handle ODBC?

Can we convince you to stop using ODBC? At the very least, stop using the sa
account for your applications. You're asking for trouble by doing this. That
sa account should be guarded as if your job depends on it, which it probably
does.

Here's a simple OLEDB connection string (I can't bring myself to type
"connectionToDatabase" when "cn" will do):

cn.open "Provider=sqloledb;data source=<name of your server>;" & _
"initial catalog=<name of database>" & _
"user id=<some account other than sa>;password=<password>"

If I can't convince you that OLEDB is better: Is the DSN a system DSN? It
needs to be.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #5
Steven Burn wrote:
How does it work if the connection is literal instead of via a DSN?

Not sure what you mean.

How would I set it up?

It works using the DSN line from VB and directly from Sql Server 7. All
of the pieces (Web Server, Sql Server 7, and Browser) are on the same
machine.

Tom.

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Thomas Scheiderich <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
Steven Burn wrote:

Try the following;

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "Customer", "sa", ""

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>


No, same error. I am running on W2k. Do I need to do something special
with the Web Server to handle ODBC?

Tom.

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Thomas Scheiderich <tf*@deltanet.com> wrote in message
news:40************@deltanet.com...
I have a page that is trying to connect to my SQL Database. All the
code I have seen shows me to connect the same way. The error I am
getting says:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/connectDB.asp, line 13
Now I know the DSN is there, because my VB program uses it on the same
machine. I copied the Open string directly from the VB program. This
is the same format I find in all my other examples. None have any
default drivers specified.

Here is the HTML file:
********************************************** ***********************
<html>
<head>
<title>ABC Corporation</title>
</head>
<body>

<h2>ABC Corporation Employee Extensions</h2>
<p>

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "DSN=Customer;" & _
"UID=sa;PWD="

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

</body>
</html>
********************************************** ***********************

What am I missing?

Thanks,

Tom.



Jul 19 '05 #6
Bob Barrows [MVP] wrote:
Thomas Scheiderich wrote:
No, same error. I am running on W2k. Do I need to do something
special with the Web Server to handle ODBC?

Can we convince you to stop using ODBC? At the very least, stop using the sa
account for your applications. You're asking for trouble by doing this. That
sa account should be guarded as if your job depends on it, which it probably
does.

I was only using ODBC, because there is a problem I have not been able
to solve on setting up UDL file. My W2K is missing something, but it
won't handle the file correctly. My other W2K machine does it fine. I
finally got tired of dealing with it, so I just used ODBC.

Just out of curiosity, why do you like OLEDB better? I heard there
wasn't much difference (I'm sure I am wrong here).

Also, I am only using my sa account on my lab rat machine. I would
never use SA on my normal machines. I agree this would be trouble if I did.

Here's a simple OLEDB connection string (I can't bring myself to type
"connectionToDatabase" when "cn" will do):

cn.open "Provider=sqloledb;data source=<name of your server>;" & _
"initial catalog=<name of database>" & _
"user id=<some account other than sa>;password=<password>"

If I can't convince you that OLEDB is better: Is the DSN a system DSN? It
needs to be.

This was the problem. As soon as I changed the DSN from user to a
system DSN, it came up correctly.

But I can't get your OLEDB one to work. It says the logon is wrong.
But the ODBC doesn't have a problem and I use the same logon. Here are
the 2 files:

The ODBC file. This one works fine now.
************************************************** ***********************

<html>
<head>
<title>ABC Corporation</title>
</head>
<body>

<h2>ABC Corporation Employee Extensions</h2>
<p>

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "DSN=Customer;user id=SA;password="

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

</body>
</html>
************************************************** ***********************

The OLEDB file. I tried using the actual data source name as well as local

and tried it with and without the initial catalog.
************************************************** ***********************
<html>
<head>
<title>ABC Corporation</title>
</head>
<body>

<h2>ABC Corporation Employee Extensions</h2>
<p>

<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "Provider=sqloledb;data source=(local);" & _
"initial catalog=CIS" & _
"user id=SA;password="

connectionToDatabase.Close
Set connectionToDatabase=Nothing
%>

</body>
</html>
************************************************** ***********************

I get the following error messag on the error page:
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E4D)
Login failed for user 'IUSR_ALLOSAURUS'.
/connectDB.asp, line 13
I would like to find out why it won't work.

I assume that since the error is a login error, that it is getting to
the server OK (maybe an incorrect assumption, however).

Thanks,

Tom.

Bob Barrows


Jul 19 '05 #7
Thomas Scheiderich wrote:

I was only using ODBC, because there is a problem I have not been able
to solve on setting up UDL file. My W2K is missing something, but it
won't handle the file correctly. My other W2K machine does it fine.
I finally got tired of dealing with it, so I just used ODBC.

Just out of curiosity, why do you like OLEDB better? I heard there
wasn't much difference (I'm sure I am wrong here).
The main reason is here:
http://msdn.microsoft.com/library/en...components.asp

There is a great deal of difference: There are two libraries involved when
using ODBC: the OLEDB library (which is the only library that ADO can use to
communicate with databases), and the ODBC library. When you use the OLEDB
provider for your database, the only library involved is the OLEDB library,
which means there is one less layer of software between your application and
the database, leading to more robustness and efficiency.
Also, I am only using my sa account on my lab rat machine. I would
never use SA on my normal machines. I agree this would be trouble if
I did.

Here's a simple OLEDB connection string (I can't bring myself to type
"connectionToDatabase" when "cn" will do):

cn.open "Provider=sqloledb;data source=<name of your server>;" & _
"initial catalog=<name of database>" & _
"user id=<some account other than sa>;password=<password>"

If I can't convince you that OLEDB is better: Is the DSN a system
DSN? It needs to be.
The OLEDB file. I tried using the actual data source name as well as
local

and tried it with and without the initial catalog.
<snip of all the html - why did we need to see that?>
<%
Set connectionToDatabase=Server.CreateObject("ADODB.Co nnection")
connectionToDatabase.ConnectionTimeout = 60
connectionToDatabase.Open "Provider=sqloledb;data source=(local);" & _
"initial catalog=CIS" & _
"user id=SA;password="


The problem here is the lack of a semicolon after "CIS".

I'm hoping you simply censored the password (it's helpful if you use the
string "<censored>", or even "XXXX" instead of leaving it blank. That way we
don';t have to wonder if you've made a mistake.). If you haven't assigned a
password to the sa account, you are asking for trouble: many viruses, (Code
Red comes to mind) were able to work because sa accounts were not assigned
passwords.
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E4D)
Login failed for user 'IUSR_ALLOSAURUS'.
/connectDB.asp, line 13


As for your error message, I am very puzzled. Without the semicolon, I got a
different error: Invalid authorization specification

With the semicolon, it works fine:

dim cn
set cn=createobject("adodb.connection")
cn.open "Provider=sqloledb;data source=(local);" & _
"initial catalog=pubs;" & _
"user id=sa;password=<censored>"

if cn.state=1 then
Response.Write "Connection opened"
else
Response.Write "Connection not opened"
end if
on error resume next
cn.close:set cn=nothing

Without the password, I get a login failed for user 'sa'. Are you sure
you're showing us the connection string that produced that error? The only
way I can get your error is if I change it to:

cn.open "Provider=sqloledb;data source=(local);" & _
"initial catalog=pubs;" & _
"Integrated Security=SSPI"

I expect to get this error because no account has been created in SQL Server
for the Internet Guest Account (IUSR_machinename). It is not recommended
that you use integrated security from asp. If you have the recommended
configuration where IIS and SQL Server are on different machines, a domain
account has to be used to connect to the server. It can be difficult to
manage security this way. Go back to the first method (just include the
semicolon I inadvertantly left out of my example)

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by Steve | last post: by
1 post views Thread by Markw | last post: by
3 posts views Thread by yawnmoth | last post: by
16 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.