clangl
asked on
Passing ADO Recordset to COM Object to Create Table Dynamically.
I am trying to create a table dynamically on an ASP. Here is the VB cls I created for FimEntry.clsTblFrmt.
Public Function CreateEntryTable(objRs As Recordset, strTlt As String, strType As String) As String
Dim strTable As String, intCount As Integer, objFld As ADODB.Field
intCount = 0
strTable = "<TABLE cellSpacing=1 cellPadding=1 width='100%' bgcolor=White border=2>"
strTable = strTable & "<TR>"
strTable = strTable & "<TD borderColorLight=white>"
strTable = strTable & "<P align=center><FONT size=6><STRONG>" & strTlt & "</STRONG></FONT></P></TD> </TR>"
strTable = strTable & "<TR>"
strTable = strTable & "<TD>"
strTable = strTable & "<TABLE borderColor=white cellSpacing=1 cellPadding=1 width='100%' border=1>"
strTable = strTable & "<TR>"
' <TD align=middle width="50%"><STRONG>Motor< /STRONG></ TD>
' <TD align=middle width="50%"><STRONG>Cognat ive</STRON G></TD></T R>
strTable = strTable & "<TR>"
For Each objFld In objRs.Fields
strTable = strTable & "<TD>"
strTable = strTable & "<TABLE cellSpacing=1 cellPadding=1 width='100%' align=left border=1>"
strTable = strTable & "<TR>"
' Assuming that the first position (0) of the RS is the account number
strTable = strTable & "<TD width='50%'>" & objFld.Name & "</TD>"
strTable = strTable & "<TD width='50%'><INPUT id=txt" & objFld.Name & " name=txt" & objFld.Name & " value = " & objRs(intCount) & "></TD></TR></TABLE></TD>"
intCount = intCount + 1
Next
strTable = strTable & "</TR></TABLE>"
CreateEntryTable = strTable
End Function
THis will return to string that creates the table. Here is the ASP
<%@ Language=VBScript %>
<% Response.Buffer=true %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<% dim objFIM, lngAcct, objScores, objTbl, strHTML
set objFIM= Server.CreateObject("FimEn try.clsSco re")
set objTbl=Server.CreateObject ("FimEntry .clsTblFrm t")
lngAcct=Request.QueryStrin g("txtAcct ")
objFIM.UserName=(Session(" UserID"))
objFIM.UserPass=Session("P wd")
set objScores=objFIM.GrabScore s(lngAcct)
'Response.Write "Acct: " & lngAcct
'Check for being set to Nothing
if not(objScores is nothing) then
'aryScr=objScores.GetRows( )
objScores.MoveFirst
Response.Write objScores(0)
strHTML=objTbl.CreateEntry Table(objS cores,"a", "b")
Response.Write strHTML
else
Response.Write "NEW SCORES:"
End if
This bombs out on the line
strHTML=objTbl.CreateEntry Table(objS cores,"a", "b")
the error
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'CreateEntryTable'
If I run a VB app it returns the correct string.
I would like to use the Recorset object B/C it will give me alot more flexability.
HELP
Public Function CreateEntryTable(objRs As Recordset, strTlt As String, strType As String) As String
Dim strTable As String, intCount As Integer, objFld As ADODB.Field
intCount = 0
strTable = "<TABLE cellSpacing=1 cellPadding=1 width='100%' bgcolor=White border=2>"
strTable = strTable & "<TR>"
strTable = strTable & "<TD borderColorLight=white>"
strTable = strTable & "<P align=center><FONT size=6><STRONG>" & strTlt & "</STRONG></FONT></P></TD>
strTable = strTable & "<TR>"
strTable = strTable & "<TD>"
strTable = strTable & "<TABLE borderColor=white cellSpacing=1 cellPadding=1 width='100%' border=1>"
strTable = strTable & "<TR>"
' <TD align=middle width="50%"><STRONG>Motor<
' <TD align=middle width="50%"><STRONG>Cognat
strTable = strTable & "<TR>"
For Each objFld In objRs.Fields
strTable = strTable & "<TD>"
strTable = strTable & "<TABLE cellSpacing=1 cellPadding=1 width='100%' align=left border=1>"
strTable = strTable & "<TR>"
' Assuming that the first position (0) of the RS is the account number
strTable = strTable & "<TD width='50%'>" & objFld.Name & "</TD>"
strTable = strTable & "<TD width='50%'><INPUT id=txt" & objFld.Name & " name=txt" & objFld.Name & " value = " & objRs(intCount) & "></TD></TR></TABLE></TD>"
intCount = intCount + 1
Next
strTable = strTable & "</TR></TABLE>"
CreateEntryTable = strTable
End Function
THis will return to string that creates the table. Here is the ASP
<%@ Language=VBScript %>
<% Response.Buffer=true %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<% dim objFIM, lngAcct, objScores, objTbl, strHTML
set objFIM= Server.CreateObject("FimEn
set objTbl=Server.CreateObject
lngAcct=Request.QueryStrin
objFIM.UserName=(Session("
objFIM.UserPass=Session("P
set objScores=objFIM.GrabScore
'Response.Write "Acct: " & lngAcct
'Check for being set to Nothing
if not(objScores is nothing) then
'aryScr=objScores.GetRows(
objScores.MoveFirst
Response.Write objScores(0)
strHTML=objTbl.CreateEntry
Response.Write strHTML
else
Response.Write "NEW SCORES:"
End if
This bombs out on the line
strHTML=objTbl.CreateEntry
the error
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'CreateEntryTable'
If I run a VB app it returns the correct string.
I would like to use the Recorset object B/C it will give me alot more flexability.
HELP
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
BEUTIFUL!!!!! Thank you.... Talk about Service
your code will not need to change in the function itself.