|
-
Aug 11th, 2004, 04:18 AM
#1
Thread Starter
Hyperactive Member
Type Mismatch problem
Hi,
I'm calling from ASP a function in MTS COM which was written in VB6 as:
Public Function GetStartTime(ByVal pstrClassCode As String) As ADODB.Recordset
and I call it in ASP like:
set rs2 = com.GetStartTime(rs.Fields("camtcd_class_code"))
The problem is that, if I don't use cstr() to enclose the parameter in asp, I will get the type mismatch error.
I read from msdn that, this error will occur when passing byref parameter, it must be defined as variant type. However, this seems does not match to my situation, can anyone tell me the problem?
Thx!!
-
Aug 11th, 2004, 04:48 AM
#2
Re: Type Mismatch problem
Originally posted by stm
Hi,
I'm calling from ASP a function in MTS COM which was written in VB6 as:
Public Function GetStartTime(ByVal pstrClassCode As String) As ADODB.Recordset
and I call it in ASP like:
set rs2 = com.GetStartTime(rs.Fields("camtcd_class_code"))
The problem is that, if I don't use cstr() to enclose the parameter in asp, I will get the type mismatch error.
I read from msdn that, this error will occur when passing byref parameter, it must be defined as variant type. However, this seems does not match to my situation, can anyone tell me the problem?
Thx!!
Unlike VB6, In ASP/VBScript there is only "one" data type available and thats Variant. For example if you define a string in VB6 it would be :
Code:
Dim strMyString As String
Now in ASP/VBScript you will simply write :
Now that variable you defined is not a string rather a Variant, so when you pass that to your VB6 function which is expecting a String, you would get Data Type error. So thats why you would need to convert the variant to string using CStr.
So in summary, VBScript only have one Data Type and thats Variant.
Hope this helps.
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Aug 11th, 2004, 10:05 PM
#3
Thread Starter
Hyperactive Member
Okay..........but it is strange that, such code (w/o cstr) is already running on NT4 machine in production env. without problem. I only encounter this problem when I test it under W2K server (prepare for upgrade), is there any change that cause this error?
Thx!
-
Aug 14th, 2004, 09:14 AM
#4
Originally posted by stm
Okay..........but it is strange that, such code (w/o cstr) is already running on NT4 machine in production env. without problem. I only encounter this problem when I test it under W2K server (prepare for upgrade), is there any change that cause this error?
Thx!
I have not come accross it, probably W2K server users updated version of VBS Engine and that enforces this type check. Thats the most likely reason. If you search MSDN/Google you will probably find the answer.
Danial
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|