cancel
Showing results for 
Search instead for 
Did you mean: 

Connect to other database

Former Member
0 Kudos

Hi,

I have a addon running and want to make a connection with another database to collect some data. It is on the same server, same user, etc.

The easy way looks like:

nCompany = New SAPbobsCOM.Company

nCompany.Server = B1Connections.diCompany.Server

nCompany.LicenseServer = B1Connections.diCompany.LicenseServer

nCompany.CompanyDB = "Other_Db"

nCompany.UserName = B1Connections.diCompany.UserName

nCompany.Password = B1Connections.diCompany.Password

nCompany.DbUserName = B1Connections.diCompany.DbUserName

nCompany.DbPassword = B1Connections.diCompany.DbPassword

This doesn't work!

I guess this is because of passing the passwords.

Is this possible in any way?

Kind regards,

John

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

It is not possible to connect another company using any existing company object even if you provide valid DB Server Type since Password Properties are empty while retrieving.

If you want to access another database table in same server, you can access with full db name like this [OTHER_DB_NAME].[dbo].[table] and make use of existing company record set to execute. This logic works in SQL Server but not sure about DB2 and Sybase. (Avoid using this in generalized add-ons or product add-ons)

In case if you want to use DI API other company, then it is not possible.

HTH

B Ravi Shankar

Former Member
0 Kudos

Hi,

Thank you. This is a clear answer.

I will use this method.

Regards,

John

Former Member
0 Kudos

Your company is connected to some particular database and if you want to connect to another database you should first disconnect from current company

(oCompany.Disconnect) and only then connect to another company and database

(every company is connected to only one database besides SBOCommon database so you can't switch from one database to another by keeping the same company active). If you do not want to disconnect from current company you can use standart DataSet and DataAdapter objects from System.Data namespace (though I have never done so)

And in your code you should initialize oCompany.DBServerType property.

Arsen Yeghiazaryan

Eneveux
Product and Topic Expert
Product and Topic Expert
0 Kudos

John,

Have you looked at the sample code that comes with the SDK and the DI API? Have your tried any of the samples as far as being able to connect to a company?

You may also need to add your DbServerType to your code such as ...

oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005

You can see the different server types by looking at the SDK Help Center documentation under DbServerTypes.

Eddy