Question

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?

Was it helpful?

Solution

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/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top