0

I am trying to connect to sql express db and inserting record to one of the table inside it using following code.

set conn=Server.CreateObject("ADODB.Connection") 
    SQL_Conn_STRING = "Driver={SQL Server};Server=(local);Database=classic_asp_poc;uid=my-domain\username;pwd=my password"      
    conn.Open SQL_Conn_STRING
    Response.Write("con open")

I am getting error on open connection. Is there any problem in my connection string?

user3030342
  • 111
  • 1
  • 2
  • 13
  • As @John has already answered SQL Server Express uses a `Named Instance` as the `Default Instance` is used by full editions of SQL Server and allows them to coexist. – user692942 May 05 '14 at 11:54

1 Answers1

1

If you're using mssql express, you need to add \SQLEXPRESS to your database address/ip, so in your example you would use Server=(local\SQLEXPRESS)

You're using an odbc connection string. OLEDB or native client strings are the preferred method eg

SQL_Conn_STRING = "Provider=sqloledb;Data Source=local\SQLEXPRESS;Initial Catalog=classic_asp_poc;User Id=my-domain\username;Password=my password"

See this easy to remember link for more examples

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

John
  • 4,658
  • 2
  • 14
  • 23