Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 ASP vs. SQL

Author  Topic 

squall leonhart
Starting Member

4 Posts

Posted - 2006-04-07 : 07:32:39
I tried to connect asp with SQL Server but it doesn't work. This is my code:

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>

<%
conn = "Provider=SQLOLEDB.1;Data Source = "
+ Server.Mappath="/aspProductCatalog/database/aspProduct_Data.mdf"

%>

<%
var rs, rs2, cn, msg

cn = Server.CreateObject("ADODB.Connection");
cn.Open(conn);
rs = Server.CreateObject("ADODB.Recordset");
sqlstring = "Select * From Admin"
rs.open(sqlstring, cn);

%>
=============
Error Type:
Microsoft OLE DB Provider for SQL Server (0x80004005)
[DBNETLIB][ConnectionOpen (ParseConnectParams()).]Invalid connection.
/aspProductCatalog/test.asp, line 13



* This is the first time I post topic, so maybe I make some mistakes, plz forgive me!

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2006-04-07 : 07:54:29
print the contents of CONN and see if the path is absolutely correct. is it possible the / should be \???
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-04-07 : 07:58:11
Your connection string looks more like Access (which identifies a specific database file) rather than SQL Server (which identifies a Server and Database name).

See http://www.connectionstrings.com/ for examples

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-07 : 08:54:04
Also, post your questions at relevent forums like Developer,etc. This is the forum to post workable scripts

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

squall leonhart
Starting Member

4 Posts

Posted - 2006-04-07 : 21:02:23
Thanks all for the advice. I tried again.
Go to Top of Page
   

- Advertisement -