Using ASP with VB Components
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