Click to See Complete Forum and Search --> : VB com object having problem in ASP


rshekhar
October 18th, 2001, 03:22 AM
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

phunkydude
October 18th, 2001, 06:32 AM
Is the objChannel object instantiated in the ASP and which component is exposing this objChannel?

rshekhar
October 18th, 2001, 10:27 PM
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

Cakkie
October 19th, 2001, 01:45 AM
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

BYaman
October 19th, 2001, 06:02 AM
hi
Don't declare your variables .
and don't use option explict.

rshekhar
October 21st, 2001, 08:39 PM
Hi thangs for your response,

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

rshekhar
October 21st, 2001, 08:41 PM
Hi thanks for your response

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

mpaul
November 2nd, 2001, 10:55 PM
Declare the argument in methods as Variant instead of object.
it will be slved.else use conversion functions
regards

rshekhar
November 7th, 2001, 01:45 AM
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