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
Solved

passing recordset from asp to a dll

Posted on 2001-08-01
19
278 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 

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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

791 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