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

Lets 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 long time but, still there are some website running in Classic ASP which need 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



About the Author


Software Engineer, Blogger etc., Visit my Youtube channel - <a href="http://www.youtube.com/agurchand">Click Here</a>

Leave a Reply

Your email address will not be published. Required fields are marked *