MS SQL


How do I connect to MSSQL using Classic ASP?
Method 1
"Provider=SQLOLEDB;Data Source=myServerAddress;UID=myUsername; PWD=myPassword; database=myDataBase;"

Method 2 Using a driver
"Driver={SQL Server Native Client 10.0}; Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;"

Method 3
Set strConnString=Server.CreateObject("ADODB.CONNECTION")
connect = "Provider=SQLOLEDB;Data Source=.\SQLEXPRESS;UID=USERNAME; PWD=PASSWORD; database=DB;"
strConnString.ConnectionString = connect
strConnString.Open

Note: New server is setup with SQL Server 2012 Standard Edition. so connection strings using ".SQLExpress" or "localhostSQLExpress" will not work. Connection strings will need to be updated to just "localhost".

If the connection strings were encrypted in web.config, those will need to be re-encrypted on new server.
Tips:
Note: myDataBase and myUsername and myPassword are what you've already specified in the control panel under MSSQL databases. myServerAddress should be 'localhost'. (New server is setup with SQL Server 2012 Standard Edition. so connection strings using ".SQLExpress" or "localhostSQLExpress" will not work, use only "localhost")

Further Reading