views:

83

answers:

1

Hi,

I'm trying to make a connection to sql server database(hosted on localhost) but keep getting the error mentioned in the title.

    Application("ConnectionString") = "Provider=SQLOLEDB;Data Source=localhost\SQLExpress;Database=mydb;Trusted_Connection=yes;UID=dbadmin; PWD=dbadmin" 
Application("ConnectionTimeout") = 15
Application("CommandTimeout") = 90
Application("CursorLocation") = 3

strQuery = "select * from dec_users"
Set objDBConnection = Server.CreateObject("ADODB.Connection")

objDBConnection.open Application("ConnectionString")
Set RS = Server.CreateObject("ADODB.RecordSet")

RS.Open strQuery, objDBConnection

any ideas?

A: 

You are putting it wrong, change to:

Application("ConnectionString") = "Provider=SQLOLEDB.1;Integrated Security=SSPI;
        Persist Security Info=False;User ID=dbadmin;Initial Catalog=mydb;
        Data Source=localhost\SQLExpress;Password=dbadmin"

(Linebreaks added for legibility)

When in doubt, create a .UDL file, construct the ConnectionString using the GUI, and then copy paste the ConnectionString (opening the file with notepad)

Eduardo Molteni
ok created the udl file...and was finally able to connect. came across another glitch and think it was due to the sqlserver browser services not running. able to connect, read and write now.
thegunner