Lesson 3:the ASP File
--------------------------------------------------------------------------------
How2project4.asp
The ASP Code
We can now use my component from any ASP page. Here we set our connection string, the SQL statement, and
The number of fields that we SQL statement returns from the database. All this variables could be set
Locally in the MethodName () method instead of being sent as method parameters.
<%
"~~~~~~~~~~~~~~~~~~ Set Object ~~~~~~~~~~~~~~~~~
Set Oclass = Server.CreateObject ("How2project4.classname"
"~~~~~~~~~~~~ Set Method Parameters ~~~~~~~~~~~~~
strdbconnectionstring = "strDSN"
strSQL = "Select Examplefieldid, ExampleField1, ExampleField2 from Exampletable"
Intfieldcount = 3
"~~~~~~~~~~~~~~ Get TABLE ~~~~~~~~~~~~~
STRHTMLTABLETR = Oclass.methodname (strdbconnectionstring, strSQL, Intfieldcount)
%>
<table border= "1" cellspacing= "3" >
<%= Strhtmltabletr%>
</TABLE>
</BODY></HTML>
<%
Set Oclass = Nothing
%>
Once the object is instantiated and the method called, a fully formed TABLE record (TR) would be returned
As a string. Placing it between opening and closing TABLE tags would display the following:
1 Text Field 2a
2 Text Field 2b
3 Text Field 2c
4 Text Field 2d
5 Text Field 2e
6 Text Field 2f
Again, for more specific information in the database used here, and a alternative way to populate an ASP
Table, read the "How to pass a Variant Array populated with a RecordSet from a VB Component to an ASP
File "and" "How to", "a RecordSet from a VB Component to a ASP File" articles.
Happy coding .....