on 2005 Jul 18 3:48 PM
Hello,
I can connect with VB.NET, but I cant do it with C#.
I was traslated the sintax of same code in each language, but doens't work.
Also, I was include one VB project into my .NET solution, but the same function that work at VB.NET solution, called from my project C# doesn't work.
¿any idea?, thanks
the code C#:
-
-
private SAPbobsCOM.Company ConnectDataBase(string dbName)
{
try
{
Company vCompany ;
int lRetCode;
int lErrCode;
string sErrMsg;
vCompany = new SAPbobsCOM.Company();
vCompany.Server = "(local)";
vCompany.CompanyDB = dbName;
vCompany.UserName = "manager";
vCompany.DbUserName = "sa";
vCompany.DbPassword = "";
vCompany.Password = "manager";
vCompany.language = SAPbobsCOM.BoSuppLangs.ln_Spanish;
vCompany.UseTrusted = false;
lRetCode = vCompany.Connect();
lRetCode = vCompany.Connect();
if(lRetCode != 0)
vCompany.GetLastError(out lErrCode, out sErrMsg);
return vCompany;
}
catch(Exception ex)
{
string mess = ex.Message ;
return null;
}
}
the code VB:
-
-
Public Function ConnectDataBase(ByVal dbName As String) As SAPbobsCOM.Company
Dim vCompany As SAPbobsCOM.Company
Dim lRetCode, lErrCode As Long
Dim sErrMsg As String
Dim strCookie As String
Dim strConnectionContext As String
Try
vCompany = New SAPbobsCOM.Company
vCompany.Server = "(local)"
vCompany.CompanyDB = dbName
vCompany.UserName = "manager"
vCompany.DbUserName = "sa"
vCompany.DbPassword = ""
vCompany.Password = "manager"
vCompany.language = SAPbobsCOM.BoSuppLangs.ln_Spanish
vCompany.UseTrusted = False
lRetCode = vCompany.Connect
If lRetCode <> 0 Then
vCompany.GetLastError(lErrCode, sErrMsg)
End If
Return vCompany
Catch ex As Exception
Return Nothing
End Try
End Function
thanks.
Hi Angel,
I copy/paste your code and obtain the error code -116, and was for you connect two times consecutively, remove one and connect perfectly.
Best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
I too copy/paste (like David) in a new project C#, and it works, then I make a DLL with the same code and too works, BUT the same DLL doesn't work into a Web Service.
I think that is the problem, because my main project is a Web Service.
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also program in C#, this is my code, works like a charm...
<b>Code (C#)</b>
SboGuiApi = new SAPbouiCOM.SboGuiApiClass();
ConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString();
SboGuiApi.Connect(ConnectionString);
SAPbouiCOM.Application SBO_Application = SboGuiApi.GetApplication(0);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
112 | |
9 | |
8 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.