dcsimg
December 5, 2016
Hot Topics:

Using ASP with VB Components

  • November 19, 2002
  • 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:

Conn.Open("People")
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
Do
Response.Write RS("PersonFName") & " " & RS("PersonLName")
RS.Movenext
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



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

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

Sitemap | Contact Us

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