Connect to MS SQL Server database from ASP

This article shows how to connect to MySQL database from Classic ASP. You can connect to your MS SQL Server database OLEDB provider or SQL Server driver. The first example show how to connect to MS SQL db from ASP with the OLDEB provider:

1. ASP to MS SQL Server database connection with OLE DB:

Set oConnection = Server.CreateObject("ADODB.Connection")

oConnection.Open "Provider=SQLOLEDB; Data Source=; Initial

Catalog=; User ID=; Password="

oConnection.Close

Set oConnection = Nothing

The example above just opens a connection from ASP to a SQL Server database and then closes it immediately. Most likely you will want to do more than just connecting to the db, but this is out of the scope of this article.

2. ASP to MS SQL Server database connection with SQL Driver:

Set oConnection = Server.CreateObject("ADODB.Connection")

oConnection.Open "Driver={SQL Server};" & _

"Server=;" & _

"Database=;" & _

"Uid=;" & _

"Pwd=;"

oConnection.Close

Set oConnection = Nothing

This ASP to MS SQL Server connection example again opens a connection, and then closes it right away.