Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP and ADO Recordset

Status
Not open for further replies.

VB400

Programmer
Sep 8, 1999
359
US

I have a Business Object in a DLL that returns a recorset object. Usually, I have a VB front-end that receives the recordset object and displays it in VB forms.

I have a new requirement to display the same recordset but on a web page (intranet) instead of VB forms. Here's the code that I tried:

<%
Set objSvr = Server.CreateObject(&quot;MyServer.MyClass&quot;)
Set rs = objSvr.GetReportData(&quot;Report Name&quot;)
Response.Write rs.Recordcount
Set rs = Nothing
Set objSvr = Nothing
%>

I get the following Error

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'objSvr.GetReportData'

/MtWeb/rsTest.asp, line 2

Any help would be greatly appreciated.

Thanks! Tarek
 
There must be something about the way you have registered your component to the server, or it's something with the COM object itself. Is the component registered? If so, are you sure the GetReportData() is a valid method for your object? I hope this helps, but it's quite hard to tell what the problem is since I do not know your component. :)


<webguru>iqof188</webguru>
 
I think the problem is that you need to instantiate a recordset object first (before you call your method that returns one).

So do this:

Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

then, do
Set rs = objSvr.GetReportData(&quot;Report Name&quot;)

Hope this helps.
 

iqof188,

Yes, the component is registered properly and so is ADO. I know this for a fact since I can use a VB front-end and get the component to return the recordset.

GlennBSI,

I added that line to instantiate the recordset first but it didn't help!

Any other thoughts?
Tarek
 
Have you tried on line 2:

rs = objSvr.GetReportData(&quot;Report Name&quot;)
instead of:
Set rs = objSvr.GetReportData(&quot;Report Name&quot;)

I've heard other stories of ASP returning errors like this due to the fact that ASP reads every variable as Variant. Is your component returning the information as a Variant?


 
I'm not sure that it is the variant problem, but here's a way to test. Use:

somestring = TypeName(rs)

to find out the subtype of the rs variable. In VBS and ASP everything is a variant, but normally it will automatically convert from different subtypes when it needs to. Normally when you get type errors is when you are trying to perform math on strings (without any numbers at all). Even then, they should just evaluate to zero.

Hope that helps. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
Oh Geez,

hblackorby, you had the right idea. In my code, I was sending the Report Name as a variable:

Set rs = objSvr.GetReportData(strRptName)

I know I published:
Set rs = objSvr.GetReportData(&quot;Report Name&quot;)

My component was expecting a string variable. As you mentioned, ASP defines everything as variant. I changed the code to:

Set rs = objSvr.GetReportData(cstr(strRptName))

and it worked. The problem wasn't with ADO at all -- my bad.

Sorry if my assumption led you down the wrong trail and thanks everyone for your help.

Lesson 1: Remember that ASP defines all variables as variants
Lesson 2: When asking for help, don't assume anything and present the complete problem
Tarek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top