February 25, 2021
Hot Topics:

Using ASP with VB Components

  • By Sam Huggill
  • Send Email »
  • More Articles »

I will now take you through a sample ASP script that uses ADO to write the contents of a recordset to an HTML page. The first line is to create a connection object:

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

Now open a DSN, in this case People, and execute an SQL (Structured Query Language) query to create a recordset object:

Set RS = Conn.Execute("SELECT * FROM Persons")

Simple enough. We now need to iterate through all the records in the Persons table, and write then, in a very simple way, to the HTML page:

If Not RS.EOF Then
Response.Write RS("PersonFName") & " " & RS("PersonLName")
Loop Until RS.EOF
End If

In the first line, we check that the table is not empty, and we then proceed to loop through the Persons table writing each PersonFName and PersonLName field to the HTML file. The Response.Write statement will write the information at the point where the ASP script is located. E.g. If above your ASP script you have header table, then the names will be written beneath that table.

Simple. But how can this help me in my Visual Basic development? Well, lets see.

Page 3 of 4

This article was originally published on November 20, 2002

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date