Solved

passing recordset from asp to a dll

Posted on 2001-08-01
19
277 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
  • 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS Question.. 3 87
Live mode in DW, need to creae Session 4 95
Connection to multiple databases 13 20
ASP server side get value 15 24
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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

803 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