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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP : Type mismatch error

Status
Not open for further replies.

cmlimnet

Programmer
Mar 7, 2002
29
IN
Dear All,
I have wrote a function known as "GetRecordset" and I put this function into a VB class and compile it into dll.
The package and class of the dll is "MyData.DataAccess".
The function's signature is shown as below.

Public Function GetRecordset( _
ByVal Connect As String, _
ByVal SQLQuery As String, _
Recordset As ADODB.Recordset) as boolean

Dim oConn As ADODB.Connection
.
.
Set oConn = New ADODB.Connection
Set Recordset = New ADODB.Recordset

Set Recordset.ActiveConnection = oConn
Recordset.CursorLocation = adUseClient
Recordset.CursorType = adOpenStatic
Recordset.LockType = adLockBatchOptimistic

'execute query and get recordset
Recordset.Open SQLQuery, , , , Options

'clean up
Set Recordset.ActiveConnection = Nothing

oConn.Close

Set oConn = Nothing

End fucntion

I have managed to call this fucntion in VB application.
But I can't call it in ASP. I knew that I passed recordset object as reference.

When I called this function in ASP,I get the error "Type Mismatch". For example,
.
.
Set obj = Server.CreateOject("MyData.DataAccess")
Set rs = Server.CreateObject("ADODB.Recordset")

obj.GetRecordset strnn, strsql, rs
.
.

How should call this function or how should pass the recordset object to this function in ASP?

Any one know this, please do help me.
Thank you very much.

Best Regard,
cmlimnet







 
Hi JohnYingling,
Thank you for your reply and suggestion.

I have tried your suggestion that to return as variant instead of boolean. But I still get the error "Type Mismatch" is my asp script. So, I think that the problem is the Recordset object that I passed into the function as third parameter.


Best Regards,
cmlimnet
 
shouldnt the api for your getrecordset be all variants, ie

Public Function GetRecordset( _
ByVal Connect As Variant, _
ByVal SQLQuery As Variant, _
Recordset As Variant) as boolean


I think this is the onlt way this will work in asp
 
Dear sjravee,

Your suggestion is correct but should return variant also. Example like below:

Public Function GetRecordset( _
ByVal Connect As Variant, _
ByVal SQLQuery As Variant, _
Recordset As Variant) as variant

This is because ASP has no any datatype except variant datatype.
 
If you define a parameter in your component ByVal then it need not be a Variant data type in the component. COM actually takes care of the "marshalling" so that a Variant in your VBScript code can be passed ByVal to, for example, an integer parameter in you component.

Here is an extract from the following link.
"ByRef parameters should be passed as Variant while ByVal parameters can be specific data types. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top