Skip to Content
0
Former Member
Apr 29, 2005 at 04:34 PM

Problem in using OCX in VB.Net - error information "Bad variant type"

125 Views

Hi,

I'm using OCX components in VB.Net,to connect to SAP and call BAPIs or ABAP functions,just like in VB(because I don't know how to use .Net Connect).Now I have the problems as described following:

When I test my project in a VB.Net windows form,it works very well.The test code(test no.1):

<b> Dim ojob As SAPJobInventory

ojob = New SAPJobInventory

ojob.Start()</b>

But when I create a new thread to run this code,the error occurs.The test code(test no.2):

<b> Dim ojob As SAPJobInventory

Dim othr As ThreadStart, o As Thread

ojob = New SAPJobInventory

othr = New ThreadStart(AddressOf ojob.Start)

o = New Thread(othr)

o.Start()</b>

The error raised at the second line in the code below:

<b>oSAPFunction = CreateObject("SAP.Functions")

oSAPFunction.Connection = oSAPConnection</b>

I have set logon parameters to oSAPConnection and call the Logon method successfully,and <b>the same code excecute correctly in test No.1,but error in test No.2</b>

The detail error message is:

err.Number:458

err.Description:Bad variant type

err.Source:wdtaocx

Could anybody have any ideas about it,or have ever met the problem just like so,or could give me some suggestions?

Thanks very much!

Best Regards.

Richie

Message was edited by: cloud yin

Message was edited by: cloud yin

Message was edited by: cloud yin

Message was edited by: cloud yin