cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to company database

Former Member
0 Kudos

I am trying to connect to the company database as suggested in DIAPI in sap b1 sample codes...I am not able to do so...

Here is the code that i wrote in C#..

company = new Company();

company.Server = "servername";

company.CompanyDB = "Training";

company.UseTrusted = true;

company.language = BoSuppLangs.ln_English;

company.UserName = "";

company.Password = "";

int retcon = company.Connect();

if (retcon != 0)

{

MessageBox.Show("The connection with the database was not established.");

}

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member201110
Active Contributor
0 Kudos

Hi Kim,

The UserName and Password must be set to values that match a user account in SAP Business One (eg a UserName of 'manager' with a password of 'manager' if you are using a test system). It doesn't matter whether you use a trusted connection or not, you must still set values to these properties (it's the DbUserName and DbPassword that don't need to be set if you use a trusted connection).

Kind Regards,

Owen

Former Member
0 Kudos

Thank you.....it worked...I was not giving the right username and password..

Former Member
0 Kudos

HI Kim,

company = new Company();

company.Server = "servername"; -->Give your server name here

company.CompanyDB = "Training";

company.UserName = "Manager"; -->your SBO USER login id

company.Password = "Manager"-->your SBO USER pwd

company.UseTrusted = true; -->When you use this no need to provide user id and pwd for database

company.language = BoSuppLangs.ln_English;

int retcon = company.Connect();

if (retcon != 0)

{

MessageBox.Show("The connection with the database was not established.");

}

OR you can use

company = new Company();

company.Server = "servername"; -->Give your server name here

company.CompanyDB = "Training";

company.language = BoSuppLangs.ln_English;

company.UserName = "Manager"; -->your SBO USER login id

company.Password = "Manager";-->your SBO USER pwd

company.DbUserName="Sa"-->Your Sql Server Login ID

company.DbPassword=""Sa"-->Your Sql Password

int retcon = company.Connect();

if (retcon != 0)

{

MessageBox.Show("The connection with the database was not established.");

}

Hope this helps you

Regards

Vishnu

Edited by: Vishnu Kumar Reddy on Dec 20, 2007 7:41 AM

Edited by: Vishnu Kumar Reddy on Dec 20, 2007 7:45 AM