Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2005, 08:35 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB code into C# code

Dear All,
can anyone pls tell me the C# code for the following:


Private Sub Form_Load()
Set oConnect = CreateObject("SAP.BAPI.1")
With oConnect.Connection
.ApplicationServer = "132.186.124.31"
.System = "00"
.User = "9999amk"
.Password = "AartiK"
.Client = "800"
.Language = "EN"

'Check if the connection was succesfully established
If Not .Logon(0, bSilentLogon) Then
MsgBox "Connection failed"
Exit Sub
Else
MsgBox "Connect successfull"
End If
End With
End Sub

thanks & regards,
muskaan.


 
Old June 16th, 2005, 10:45 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Assuming that you have a good COM reference to the SAP.BAPI.1 DLL...

Something like this should do it:

private void Form_Load(){
    SAP.BAPI.1 oConnect = new SAP.BAPI.1();

    oConnect.Connection.ApplicationServer = "132.186.124.31";
    oConnect.Connection.System = "00";
    oConnect.Connection.User = "9999amk";
    oConnect.Connection.Password = "AartiK";
    oConnect.Connection.Client = "800";
    oConnect.Connection.Language = "EN"

    //Check if the connection was succesfully established
    if(!oConnect.Connection.Logon(0, bSilentLogon)){
        System.Windows.Forms.MessageBox.Show("Connection failed");
    } else {
        System.Windows.Forms.MessageBox.Show("Connect successfull");
    }
}


-Peter
 
Old June 17th, 2005, 02:33 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter,
but am getting the following error at the if condtion.

"The event 'SAPLogonCtrl.SAPLogonControlClass.Logon' can only appear on the left hand side of += or -="

also, am not able to use the messagebox......
the intellisense is not displaying windows after system.

pls help.
regards,
muskaan.


 
Old June 17th, 2005, 08:15 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ah... well I overlooked that you posted in the ASP.NET forum. You can't use the windows forms messagebox in an ASP.NET application. You have to emit javascript to the client the calls the "alert()" method. There are several threads on this forum that describe how to do that in more detail.

I don't know what the problem is with that SAP method call. You'll have to play around with it. If the Logon() method returns a boolean, it should work mostly like I wrote above. If not, then I'm not sure what to do without being able to play with it directly.

-Peter
 
Old June 17th, 2005, 09:08 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could you pls tell me how can i convert the follwoing code into C#:

Set oBAPICtrl = CreateObject("SAP.BAPI.1")

thanx and regards,
sneha.

 
Old June 17th, 2005, 02:42 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I suggested this above. Does it not work? I don't know the exact prog ID of the COM dll you are referencing so I can't be sure that what I wrote is *exactly* correct. You'll need to discover that with a little research.

-Peter
 
Old June 20th, 2005, 04:01 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter,
am trying to run the following code:


SAPLogonCtrl.SAPLogonControlClass log=new SAPLogonControlClass();

log.ApplicationServer ="132.186.124.31";
log.System="00";
log.User="9999sde";
log.Password ="snehad";
log.Client="800";
log.Language="EN";

//Check if the connection was succesfully established
if( log.Logon(0 , false))
{
    lblexec.Text ="Connection failed";
}
else
{
    lblexec.Text ="Connection successful";
}

but am getting the following error at the if condtion.

"The event 'SAPLogonCtrl.SAPLogonControlClass.Logon' can only appear on the left hand side of += or -="

also, am not able to use the messagebox......
the intellisense is not displaying windows after system.

pls help.
regards,
muskaan.




 
Old June 20th, 2005, 07:53 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I have never seen this error:

"The event 'SAPLogonCtrl.SAPLogonControlClass.Logon' can only appear on the left hand side of += or -="

So I don't know what it means.


See my second post above regarding the message box.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I write this vb 6 code to work in vb 2008? sanderson Visual Basic 2008 Essentials 3 June 10th, 2008 01:46 PM
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
VB Code jdeaver Pro VB Databases 0 January 6th, 2004 05:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.