I am connecting to SAP via COM, using ActiveX controls dragged into the Form. In VB6 I write:
Private Sub Form_Terminate()
SAPBAPIControl.Connection.Logoff
End Sub
Private Sub SAPLogonControl_Click()
Set SAPBAPIControl.Connection = SAPLogonControl.NewConnection
SAPBAPIControl.Connection.Client = "100"
If SAPBAPIControl.Connection.Logon(0, False) Then
MsgBox SAPBAPIControl.Connection.IsConnected
End If
End Sub
In VB.NET 2010 I write:
Public Class MainForm
Private Sub MainForm_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
AxSAPBAPIControl1.Connection.Logoff()
End Sub
Private Sub AxSAPLogonControl1_ClickEvent(sender As Object, e As System.EventArgs) Handles AxSAPLogonControl1.ClickEvent
AxSAPBAPIControl1.Connection = AxSAPLogonControl1.NewConnection()
AxSAPBAPIControl1.Connection.Client = "100"
If AxSAPBAPIControl1.Connection.Logon(0, False) Then
MsgBox(AxSAPBAPIControl1.Connection.IsConnected)
End If
End Sub
End Class
and end up with:
Eine Ausnahme (erste Chance) des Typs "System.AccessViolationException" ist in mscorlib.dll aufgetreten. in .Client = "100"
VB6 just works.
Does anyone have an idea how to transfer the Connection Object to the other class in VB.NET?
Thanks for the help.