0

I am trying to connect to a production database from a C# console project in .NET6 with VS 2022 using this piece of code

using SAPbobsCOM;
void InsertarActividad()
 Company oCompany = new Company();
 oCompany.Server = "IP_Server";
 oCompany.CompanyDB = "DEMO";
 oCompany.UserName = "manager";
 oCompany.Password = "XXXXXX";
 oCompany.DbUserName = "sa";
 oCompany.DbPassword = "XXXXXX";
 oCompany.DbServerType = BoDataServerTypes.dst_MSSQL2012;
 oCompany.LicenseServer = "IPServer:30000";

 int rdoConexion = oCompany.Connect();

 oCompany.StartTransaction();
 try
    {

In rdoConnection variable I get a value of -10 and according to other code examples I think the value should be 0 because when I start the transaction it tells me that I am not connected

System.Runtime.InteropServices.COMException: ‘You are not connected to a company’

The values of oCompany are correct and in fact in an old VB.NET application that I am migrating they work and I don't know the reason why now in the same local network of the office in this project it does not connect me

Any ideas, please?

Thanks

kintela
  • 1,283
  • 1
  • 14
  • 32

1 Answers1

0

It has been fixed by replacing the server IP with its name. I don't know why this is so but at least it connects me

Thanks

kintela
  • 1,283
  • 1
  • 14
  • 32
  • It ties into licensing. Usually the server name you see in the client login window is authoritative. Also remember that at on some versions, the server name (and indeed user names) are case-sensitive. – Daz Oct 12 '22 at 10:58