472,334 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Connecting to SQL Server from ASP


Hello,

I have MS SQL Server running on a server computer. I am trying
to connect to it via ASP from a .asp file created in a virtual
directory. I am using IIS as the web server. I am connecting
from a Windows 2000 computer.

When I go to Start -> Settings -> Control Panel
-> Administrative Tools -> ODBC Data Sources

I see a data source which uses SQL Server. I click on it,
click Configure..., then Next, and notice that if I place
the password I can connect fine from the "ODBC Data Source
Administrator".

However, when i try the following from ASP I get an error:

<%

cncString = "DSN=X;" _
+ "Database=Y;" _
+ "UID=foo;" _
+ "PWD=bar"

Response.Write(cncString)

cnc.Open cncString

%>

The server error I get is the following:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/neil/Default.asp, line 30

This seems strange to me given that I can connect from the
ODBC Data Source Administrator without much trouble.

The only reason for this error which I can think of is that
the ODBC data sources may not be running on the web server
itself, but on yet a third machine, and I do not have access
to the web server itself right now, so that may be the problem.

Please let me know about any other probems which may arise
once I can get my hands on the web server itself,

Thank you so much for your suggestions and help,

Best Regards,

Neil Zanella

Jul 23 '05 #1
3 1354
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no
default driver specified
/neil/Default.asp, line 30

Make sure you created DSN with the name X

Madhivanan

Jul 23 '05 #2
> <%

cncString = "DSN=X;" _
+ "Database=Y;" _
+ "UID=foo;" _
+ "PWD=bar"


Use & to concatenate strings in ASP, not +.

Jul 23 '05 #3
Okay, the two ways I have used to connect from plain old ASP are:

1) Save a System (not User) DSN, and then set the connection string
just as:

cncString = "DSN=SqlConnect"

(if SqlConnect is the name of the DSN)

or,

2) Construct the whole connection within the ASP (dont touch ODBC at
all) such as:

cncString = "Provider=sqloledb;Data Source=" & myServer & ";Initial
Catalog=" & myDatabase & ";"

then add on either:

cncString = cncString & "Integrated Security=SSPI;"

or

cncString = cncString & "uid=" & myUser & ";pwd=" & myPassword & ";"

depending upon whether I'm using windows authentication or sql
authentication.

-------------------------------

May as well piggy back my own query on here, since it may turn out to
be relevant to OP:

We've recently been setting up an intranet site where we wanted to ID
the users from the browser using Windows Auth and then connect to the
DB as them using Windows Auth. Is there *still* no way of achieving
this when IIS/SQL are on different boxes? Any patches we may be
missing? We've switched to doing the browser authentication using basic
digest, but that isn't ideal. Windows/SQL are both 2000 with latest
stable SPs.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application...
3
by: Ann Marinas | last post by:
Hi there, I am currently developing an ASP.NET program that connects to a SQL Server 2000 database. I also have SQL Server 2005 Express installed...
0
by: cj.snead | last post by:
Hello, I am having trouble connecting to a remote named instance of SQL Server via Pocket PC. I have had absolutely no luck connecting with VS...
3
by: Vinod R.Shenoy | last post by:
Hi All, Came across a post wherin you had helped somebody with a similar problem and was wondering if you could help us out with it. Our...
6
by: Todd Brewer | last post by:
Windows Server 2000 ASP.NET 2.0 SQL Server 2000 (on a physically seperate server) I moved an ASP.NET 2.0 application from a development server...
10
by: mairhtin o'feannag | last post by:
Hello, I'm having problems connecting to my new v9 db box. The pertinent information is below: DB2_db2inst1 60000/tcp DB2_db2inst1_1 ...
2
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: ...
2
by: orandov | last post by:
Hi, I am having a problem connecting my .net applications from the application server to the database server. When I run the application from my...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.