Link to home
Start Free TrialLog in
Avatar of clangl
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>Cognative</STRONG></TD></TR>
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("FimEntry.clsScore")

set objTbl=Server.CreateObject("FimEntry.clsTblFrmt")
lngAcct=Request.QueryString("txtAcct")
objFIM.UserName=(Session("UserID"))
objFIM.UserPass=Session("Pwd")
set objScores=objFIM.GrabScores(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.CreateEntryTable(objScores,"a","b")
     Response.Write strHTML
else
     Response.Write "NEW SCORES:"

End if

This bombs out on the line
strHTML=objTbl.CreateEntryTable(objScores,"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
ASKER CERTIFIED SOLUTION
Avatar of jitganguly
jitganguly

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John844
John844

you will need to pass the recordset as a variant

your code will not need to change in the function itself.
Avatar of clangl

ASKER

BEUTIFUL!!!!! Thank you....  Talk about Service