473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 2184
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: StephenRichter | last post by:
I have installed the trial of db2 enterprise server on my w2k PC. Have also installed fix pack 8 of that product. I am using it to connect from an asp.net web page to an IBM as400. the 400 is...
22
by: Kristof Thys | last post by:
Hello, I'm developing a C# - windows forms application. To get some information for my application, I'm connecting to an URL, wich gives me XML generated using php. With 90% of the users, this...
0
by: vicky | last post by:
Hello Experts, Trying to run sample Postgrel's ECPG(Embedded SQL)programs on RHL 9.0. Im unable to connect to PostgreSQL database (sirishadb) when I run the program .... # su postgres...
4
by: newladder | last post by:
Hi all, Iam struck with one of the problem with postgres. Please help me out.... Iam trying to connect to connect to postgres database on remote machine with the IP address 10.2.1.4. Iam unable...
23
cyberking
by: cyberking | last post by:
Hi. I have just started learning PHP along with MySQL. I am trying to connect to the MySQL DB server but unable to. I have been tryin. Please help. Its urgent cos I shall soon have to work on...
1
by: ynyus75 | last post by:
Hey! I am unable to connect some of the services that I host from my laptop at home, such as SMTP and MySQL on port numbers 25 and 3306 respectively. But I am able to some services such as...
21
by: Steve | last post by:
I moved my database from one server to another SQL server. I did a backup and restore of the database. I can connect to the database on server A from my asp.net app but when I try to connect to my...
1
by: Markw | last post by:
Hi folks I think I've got a variable problem but not 100% sure. Background: I took the CMS example from chapter 6 in "Build your Own Database Driven Website Using PHP&MySQL" and have attempted to...
3
by: Harmony504 | last post by:
HELP! Setup: PHP5.2.5, IIS 5.1, XP, AS/400 (DB/400 or DB2) I am trying to connect to a DB2 database from my computer. I installed DB2 Connect and set up the ODBC Driver in the Data Source...
3
by: yawnmoth | last post by:
I'm trying to connect to an Active Directory server and am having some difficulties. Here's the code I'm using: <?php if (!($ldap = ldap_connect('domain.tld')) { exit('unable to connect'); }...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.