Display Data from Database in Classic ASP – Learn it here!

Let’s start how we can connect to the database and pull the records from a Table using Classic ASP.

Yes, we all know people stopped using Classic ASP for a long time but, still, there are some websites running in Classic ASP which needs some modifications right?

No worries, here is the entire script for you enjoy!


Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
'User (local) or localhost or your host ip
conn.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = mydatabase; User Id = myusername; Password=mypassword"

dim strSQL
strSQL = "select * from table_name"
Set rst = conn.Execute(strSQL)

If rst.BOF And rst.EOF Then
' No data
Do While (Not rst.EOF)
Response.Write "<tr><td>" & rst("columnname1") & "</td><td>" & rst("columnname2") & "</td></tr>"
End If




Leave a Reply

Theme: Overlay by Kaira