Results 1 to 4 of 4

Thread: Type Mismatch problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416

    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!!

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    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 :

    Code:
    Dim strMyString
    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 :

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    416
    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!

  4. #4
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    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
  •  



Click Here to Expand Forum to Full Width