Question:
ASP connection string for SQL Server 2005?
yoelbenyossef
2009-02-02 21:22:19 UTC
Hi there,
I'm trying to connect adapt some code that I wrote for an access database to an sql server 2005 database. When I try to run the code now, I get this error:

Microsoft OLE DB Provider for SQL Server error '80004005'

[DBNETLIB][ConnectionOpen (ParseConnectParams()).]Invalid connection.

My connection string in access is:
dim cnn,rst
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=c:\db\directory\directory.mdb;"

My connection string in SQL Server 2005 is:
dim cnn,rst
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.ConnectionString = "Provider=SQLOLEDB;data source=d:\hosting\HostName; database=DBName.db;Uid=xxx;Pwd=xxx;"
Cnn.Open

If anyone could tell me what I'm doing wrong, or a tutorial on how to build connection strings, it would be much appreciated.

Thanks
Eric
Four answers:
just_me ♦
2009-02-02 21:54:01 UTC
what about a stored procedure, easier to create a connection string and a way better to update
anonymous
2009-02-03 00:39:48 UTC
Try this connection string. visit These sites

http://www.connectionstrings.com/sql-server-2005.

http://www.aspnet101.com/aspnet101/tutorials.aspx?id=64
midspace
2009-02-02 21:56:13 UTC
SQL Server databases cannot be connected to by their filename.

You connect to their service running on the server, using they server or instance name.



Provider=SQLOLEDB;DRIVER={SQL Server};Server=YOURSERVERNAME;database=YOURDATABASENAME;UID=xxxxx;PASSWORD=xxxx
?
2016-05-28 09:22:26 UTC
what does your connection string look like??


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...