How to connect to the database in classic ASP?! Lets do it now!

Classic ASP is a very old language and it is not been developed for years. But, still, we can see a number of websites running in Classic ASP.

Connecting to the MSSQL database in Classic ASP is easy, Just copy paste the below code and give the username, password and run the script to see what happens.

<%

Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
'use (local) or localhost or ip address, User Id is the Username
conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = Northwind; User Id = Ticc; Password=yourpass"

'Check if it is connected to the SQL server
If conn.errors.count = 0 Then
Response.Write "Connected"
End If

%>

Leave a Reply

Theme: Overlay by Kaira
Agurchand