Solved

passing recordset from asp to a dll

Posted on 2001-08-01
19
280 Views
Last Modified: 2008-03-06
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.

0
Comment
Question by:pmacmann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +6
19 Comments
 
LVL 20

Expert Comment

by:jitganguly
ID: 6341513
Declare the VB function as variant and try like

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

0
 
LVL 2

Expert Comment

by:preinsko
ID: 6341550
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
 
LVL 20

Expert Comment

by:jitganguly
ID: 6341606
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:pmacmann
ID: 6341611
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
 

Author Comment

by:pmacmann
ID: 6341635
jitganguly -- Would
Public Function runReports(rs as variant) as boolean

work?
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 6341705
NO, use variant
It would be
Public Function runReports(rs as variant) as Variant
0
 
LVL 20

Expert Comment

by:jitganguly
ID: 6341708
NO, use variant
It would be
Public Function runReports(rs as variant) as Variant
0
 
LVL 1

Expert Comment

by:pjtt
ID: 6341871
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
 
LVL 7

Expert Comment

by:John844
ID: 6341901
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
 
LVL 1

Expert Comment

by:Maestro
ID: 6342368
i use this solution in my dll activex for my asp pages:

Public Function RunReport(rs As object) As Boolean

0
 
LVL 1

Expert Comment

by:Maestro
ID: 6342373
the exit function is variant sorry, it was a mistake: use this:

Public Function RunReport(rs As object) As variant
0
 
LVL 3

Expert Comment

by:nigelrowe
ID: 6344274
The error might be generated in the DLL. It would be wise to debug it as well.
0
 

Author Comment

by:pmacmann
ID: 6344583
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
 
LVL 1

Expert Comment

by:BenBen
ID: 6349491
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
 

Author Comment

by:pmacmann
ID: 6349907
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
 
LVL 20

Expert Comment

by:jitganguly
ID: 6349936
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
 
LVL 1

Expert Comment

by:BenBen
ID: 6350053
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
 

Author Comment

by:pmacmann
ID: 6517645
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
 
LVL 1

Accepted Solution

by:
jswalia earned 100 total points
ID: 6994659
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBScript on Html 15 65
Button function on table is in trouble 3 41
Time comparison asp 1 27
SQL to JSON 14 65
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question