SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 ASP vs. SQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

squall leonhart
Starting Member

Vietnam
4 Posts

Posted - 04/07/2006 :  07:32:39  Show Profile  Send squall leonhart a Yahoo! Message  Reply with Quote
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!

Edited by - squall leonhart on 04/07/2006 07:35:41

AndrewMurphy
Flowing Fount of Yak Knowledge

Ireland
2916 Posts

Posted - 04/07/2006 :  07:54:29  Show Profile  Reply with Quote
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

United Kingdom
22431 Posts

Posted - 04/07/2006 :  07:58:11  Show Profile  Reply with Quote
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

India
22772 Posts

Posted - 04/07/2006 :  08:54:04  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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

Vietnam
4 Posts

Posted - 04/07/2006 :  21:02:23  Show Profile  Send squall leonhart a Yahoo! Message  Reply with Quote
Thanks all for the advice. I tried again.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000