passing recordset from asp to a dll

I'm trying to pass a recordset from an asp page to a dll -- I'm getting a "Type Mismatch"  on the line
If rptServer.RunReport(rs)  then
-- any ideas?

-------------------
ASP page:
<HTML>
<HEAD>
<TITLE>VICC</TITLE>
</HEAD>
<!--#include file='inc/ADOVBS.INC'-->
<%    
     
     Dim rptServer
     Dim fname
     Dim iWhichRpt
     dim strSQL
     dim strTemp
     Dim sSchoolCode
     Dim sDistrictCode      
     dim rs, Con, SQL, cmdtemp
     
     
     Set rptServer = CreateObject("VICCReports.VICCReportServer")
     Set rs        = Server.CreateObject("ADODB.Recordset")
     Set Con       = Server.CreateObject("ADODB.Connection")
     Set cmdTemp   = Server.CreateObject("ADODB.Command")
     
     Con.ConnectionTimeout = Application("Con_ConnectionTimeout")
     Con.CommandTimeout = Application("Con_CommandTimeout")
     Con.Open Application("Con_ConnectionString"), Application("Con_RuntimeUserName"), Application("Con_RuntimePassword")

     
    cmdTemp.CommandText = "StudentReport"
    cmdTemp.CommandType = adCmdStoredProc '4    
    Set cmdTemp.ActiveConnection = Con  
    iWhichRpt = 1
    rptServer.Report = iWhichRpt
    sSchoolCode = "4040"
    sDistrictCode = "bay"
    cmdTemp.Parameters.Append cmdTemp.CreateParameter("sSchoolCode",  adVarChar, adParamInput,4,sSchoolCode)
    cmdTemp.Parameters.Append cmdTemp.CreateParameter("sDistrictCode",  adVarChar, adParamInput,3,sDistrictCode)
    Set rs = cmdTemp.Execute              
         

    rptServer.OutputFormat = 2 ' PDF
    rptServer.EnhancedLogging = True

     If rptServer.RunReport(rs)  then
          fname = rptServer.FileName%>
          <a href="<%=fname%>">Report</a>
     <%
     ELSE
     %>
     <!-- rptServer.RunReport() failed -->
     <BODY>

     <P>
     Error: Unable to create report.<BR>
Try pressing back arrow and trying again. If the problem persists, contact...     </P>

     <%
     END IF
     %>

</BODY>
</HTML>
--------------------------
my VB dll:
Public Function RunReport(rs As ADODB.Recordset) As Boolean
etc.

pmacmannAsked:
Who is Participating?
 
jswaliaCommented:
Try something like this:

' define your local recordset on ASP Page
set rs = server.CreateObject("ADODB.RecordSet")

' define your Dll Class
set clsD = server.CreateObject("WEBDataDll.clsData")
   
' make SQl string
strSQL = "Select cUserid,cPassword from Users where "
strsql = strsql & "upper"(cUserID) = '"
strsql = strsql & ucase(Request.Form("UID")) & "'"

' Call your function from Dll & assign it to the local recordset variable
' See carefully that we are passing the parameter in 2 braces, which is the MAIN thing to do

set rs = clsD.GetRecordset((strSQL))

if NOT rs.BOF then

else

endif
0
 
jitgangulyCommented:
Declare the VB function as variant and try like

Public Function RunReport(rs As ADODB.Recordset) As Variant
etc.

0
 
preinskoCommented:
Try setting the cursor to client side.

strConnection.CursorLocation=adUseClient and see if that helps.  Just a thought since I usually only pass one record to my business logic.  
Is there some reason the dll couldn't retreive the recordset based on some query parameters sent to the method?  Seems like overkill to obtain a recordset in asp then pass the whole thing to a dll for actual processing.

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
jitgangulyCommented:
In fact you should do it like

Public Function RunReport(rs As Recordset) As Variant

I just helped another person here with a similar problem
http://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20161735
0
 
pmacmannAuthor Commented:
preinsko -- the dll actually creates a report (using Active Reports) and it was more flexible to have unbound controls in the report -- so I need to pass the recordset to produce the report.

jitganguly -- I need the function as boolean -- it is set to true/false depending on if a report is created.

0
 
pmacmannAuthor Commented:
jitganguly -- Would
Public Function runReports(rs as variant) as boolean

work?
0
 
jitgangulyCommented:
NO, use variant
It would be
Public Function runReports(rs as variant) as Variant
0
 
jitgangulyCommented:
NO, use variant
It would be
Public Function runReports(rs as variant) as Variant
0
 
pjttCommented:
Your code looks right to me, especially if you've tried the options given. A quick fix would be to create a property and use that property in the function, ie:

Public Property Set ReportRS(ReportRS As Recordset)
  Set moReportRS = ReportRS
End Property

or something like that...

Peter Tracey
Developer
http://www.25online.com/peter
0
 
John844Commented:
you can return any data type from the function and it will assign it.  

I would not ever use properties for a component as this reduces scalability.
0
 
MaestroCommented:
i use this solution in my dll activex for my asp pages:

Public Function RunReport(rs As object) As Boolean

0
 
MaestroCommented:
the exit function is variant sorry, it was a mistake: use this:

Public Function RunReport(rs As object) As variant
0
 
nigelroweCommented:
The error might be generated in the DLL. It would be wise to debug it as well.
0
 
pmacmannAuthor Commented:
I've tried:
Public Function RunReport(rs As ADODB.Recordset) As Boolean
Public Function runReport(rs As Variant) As Variant
Public Function RunReport(rs As Object) As Variant

and continue to get the type mismatch. When I run the dll from VB - it works great. It is obtaining the recordset from a SQL stored procedure (and that hasn't changed from running it in VB or trying to run it from asp).

I'm rather new to VB -- do you have a suggestion of how to trap the error in the dll (if that's the case) and write it in the app.logevent or pass it back?

thanks.
0
 
BenBenCommented:
Try
public proporty set RS(RS as adodb.recordset)
OR a much better soultion (IMHO) would be to pass the CONNECTION STRING AND THE QUERY to VB and use VB to connect. To debug this application, try doing this. Make a new project that is the same as your ASP code. (the vbs part) and set the dll to run that when ever it is debugged. put a break on every line
0
 
pmacmannAuthor Commented:
Actually, this application runs fine in VB - it's just when I try to reference the dll from asp that I get the type mismatch.
0
 
jitgangulyCommented:
What is preventing you to do it like
Public Function RunReport(rs As ADODB.Recordset) As Variant

and use cstr function of vbscript to access it. It shoudl be simple

0
 
BenBenCommented:
Try doing

Public proporty set rs (rs as object)

Because vbs has no dim as ____ statements i think the mechiene just cant handle that.
0
 
pmacmannAuthor Commented:
I've tried all of these suggestions -- I think it may be a problem with Active Reports. I'll keep you posted. thanks for all of your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.