CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2001
    Location
    Singapore
    Posts
    8

    VB com object having problem in ASP

    Hi there,

    I'm facing serious problem in ASP.

    I'm calling my own VB com object to update the user details to the database.

    VB com object passing parameter data type is object. From ASP i'm try to pass the object to Update interface immediately i'm getting error from the Browser that "data type mismatch"

    ------------------------------------------------------------------------------------
    Public Function update(objChannel As Object) As Boolean

    Dim strSQL As String
    Dim blnCon As Boolean

    On Error GoTo errorhandler

    update = False

    If getDBConnection Then

    strSQL = "UPDATE channel " & _
    "SET description = '" & getSQLString(objChannel.Description) & "'," & _
    "password = '" & getSQLString(objChannel.PassWord) & "'," & _
    "id = '" & objChannel.ID & "'" & _
    "WHERE system_id = " & CStr(mlngSystemId)

    mcn.BeginTrans
    mcn.Execute (strSQL)

    mcn.CommitTrans

    update = True
    End If 'If getDBConnection

    closeDB
    Exit Function

    errorhandler:
    mlngErrNum = Err.Number
    mstrErrDesc = Err.Description
    update = False
    -----------------------------------------------------------------------------
    This com interface is working in VB application side, but not in ASP side.

    Please help, my deadline is nearing.
    Any kind of help or suggestion is appreciated

    Thank You




  2. #2
    Join Date
    Aug 2000
    Location
    Namibia
    Posts
    139

    Re: VB com object having problem in ASP

    Is the objChannel object instantiated in the ASP and which component is exposing this objChannel?


  3. #3
    Join Date
    Oct 2001
    Location
    Singapore
    Posts
    8

    Re: VB com object having problem in ASP

    Hi there,

    I'm facing serious problem in ASP side.

    I'm calling my own VB com object to update the user details to the database.

    VB com object passing parameter data type is object. From ASP i'm try to pass the object to Update interface immediately
    i'm getting error from the Browser that "data type mismatch"

    ----------------------------------------------------------------------------------------------------------------------------------------------
    VB Com Channel Class input parameter object data type return boolean value for update Interface
    ----------------------------------------------------------------------------------------------------------------------------------------------
    Public Function update(objChannel As Object) As Boolean

    Dim strSQL As String

    On Error GoTo errorhandler

    update = False

    If getDBConnection Then

    strSQL = "UPDATE channel " & _
    "SET description = '" & getSQLString(objChannel.Description) & "'," & _
    "password = '" & getSQLString(objChannel.PassWord) & "'," & _
    "id = '" & objChannel.ID & "'" & _
    "WHERE system_id = " & CStr(mlngSystemId)

    mcn.BeginTrans
    mcn.Execute (strSQL)
    mcn.CommitTrans

    update = True

    End If 'If getDBConnection

    closeDB
    Exit Function

    errorhandler:
    mlngErrNum = Err.Number
    mstrErrDesc = Err.Description
    update = False
    ---------------------------------------------------------------------------------------------------------------------------
    VB Application code - this code is perfectly excuting and returning the boolean value
    ---------------------------------------------------------------------------------------------------------------------------
    Private Function updateChannel() As Boolean

    Dim gobjTranzAdminMgr as object
    Dim objChannel As Object
    Dim mobjChannel As Object

    On Error GoTo errorhandler

    updateChannel = False

    Set gobjTranzAdminMgr = CreateObject("MobiSoftMOE.AdminManager")

    If Not gobjTranzAdminMgr Is Nothing Then ' this is instanciated main class

    Set objChannel = gobjTranzAdminMgr.GetChannelClass
    Set mobjChannel =gobjTranzAdminMgr.GetChannelClass

    if mobjChannel.Findbysystemid(lngsysid) then

    objChannel.Description = txtDescription.Text
    objChannel.id = mlngID
    objChannel.Password = txtPassword.Text

    If mobjChannel.Update(objChannel) Then
    updateChannel = True
    Else
    gstrErrDes = mobjChannel.errordesc
    End If
    End if
    Set mobjChannel = Nothing
    Set objChannel = Nothing
    End If
    Exit Function

    errorhandler:
    gstrErrDes = Err.Description
    glngErrNum = Err.Number
    updateChannel = False

    End Function

    --------------------------------------------------------------------------------------------------------
    ASP code - I'm unable to get the return value, its saying "Type Mismatch" of the update(objChannel)
    --------------------------------------------------------------------------------------------------------
    dim gobjTranzAdminMgr
    dim objChannel
    dim objChannelM
    dim desc
    dim id
    dim sysid
    dim pwd

    desc = Request.Form("Description")
    id = Request.Form("id")
    sysid = Request.Form("sysid")
    pwd= Request.Form("pwd")

    Set gobjTranzAdminMgr = server.CreateObject("MobiSoftMOE.AdminManager")

    If Not gobjTranzAdminMgr Is Nothing Then
    Set objChannelM = gobjTranzAdminMgr.GetChannelClass
    Set objChannel = gobjTranzAdminMgr.GetChannelClass

    objChannel.Description = cstr(desc)
    objChannel.id = clng(id)
    objChannel.Password = cstr("pwd")

    if objChannelM.FindbySystemid(clng(sysid)) then
    if objChannelM.Update(objChannel) then <<<<<<<<<<<<<<<<<<< here i'm getting error "Type Mismatch">>>>>>>>>>>>>>>>>>>
    Call Showmessage2("Channel " & msg_02, "ConChannleList.asp")
    Else
    call Showmessage("Error occured; " & objChannelM.errorDesc & msg_03 & " channel.")
    Response.End
    End If
    End if
    set objChannelM = nothing
    set objChannel = nothing
    end if
    set gobjTranzAdminMgr = nothing

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This com interface is working in VB application side, but not in ASP side.

    Please help me.
    Any kind of help or suggestion is appreciated

    Thank You

    Shekhar


  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: VB com object having problem in ASP

    This is easy,

    ASP uses VBScript, VBScript only has 1 datatype, namely variant, therefore, all values pass to a function, or returned from a funtion must be variant. This means that the declaration of the function in the Com Component must be changed to all variants:

    public Function update(objChannel as Object) as Boolean
    ' MUST BE
    public Function update(objChannel as Variant) as Variant




    Tom Cannaerts
    slisse@planetinternet.be

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: cakkie@cakkie.be.remove.this.bit
    www.tom.be (dutch site)

  5. #5
    Join Date
    Jun 2001
    Posts
    44

    Re: VB com object having problem in ASP

    hi
    Don't declare your variables .
    and don't use option explict.



  6. #6
    Join Date
    Oct 2001
    Location
    Singapore
    Posts
    8

    Re: VB com object having problem in ASP

    Hi thangs for your response,

    Yes, objChannel object has been instantiating inside the ASP, [ objTranzAdminMgr ] this component exposing the objChannel




  7. #7
    Join Date
    Oct 2001
    Location
    Singapore
    Posts
    8

    Re: VB com object having problem in ASP

    Hi thanks for your response

    I will try it and get back to you...



  8. #8
    Join Date
    Oct 2001
    Location
    Bangalore.INDIA
    Posts
    25

    Re: VB com object having problem in ASP

    Declare the argument in methods as Variant instead of object.
    it will be slved.else use conversion functions
    regards


  9. #9
    Join Date
    Oct 2001
    Location
    Singapore
    Posts
    8

    Re: VB com object having problem in ASP

    Thanks for your suggestion, its working but, My case I can’t change in my standardized COM object, because i may access from C++ , VB Application and as well JAVA application. If i look in to that, I need to convert data type in ASP side only. If you have any data type conversion function or suggestion please send me as early as possible.

    Regards
    shekhar



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

Featured