cancel
Showing results for 
Search instead for 
Did you mean: 

GetCompanyList from 05.OrderAndInvoice Sample

Former Member
0 Kudos

Good Day

Experts:

Earlier in the week, Leonardo helped me out with the line to set the dbType for SQL2005 in the code below. For the past couple of daya I have been testing with (local) for the Server. I then would get a list of db's on my local machine. However, this morning I am trying to get a list of db's from our Server but am receiving an error when executing line --> oRecordSet = oCompany.GetCompanyList.

The Server...does that just have to be the IP Address? What is the SAP code expecting here for the Server?

Thanks,

EJD

If e.KeyCode = Keys.Enter Or e.KeyCode = Keys.Tab Then

e.SuppressKeyPress = True

oCompany = New SAPbobsCOM.Company

'*****************************************

'Initialization Connection Properties

'Manadatory for SQL2005...other may differ

'*****************************************

oCompany.Server = txtServer.Text

oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005

oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English

oCompany.UseTrusted = True

oCompany.UserName = txtUser.Text

oCompany.Password = txtPassword.Text

'**************************

'Create a list of companies

'**************************

oRecordSet = oCompany.GetCompanyList

Accepted Solutions (1)

Accepted Solutions (1)

AdKerremans
Active Contributor
0 Kudos

Hi,

It worked because you used (local) as server, but when you use another server UseTrusted must be false and you should also set BDUser and DBPassword to make it work.

Regards

Ad

Former Member
0 Kudos

Hi Ad,

Thanks for replying. I have made sure my Trusted setting is equal to True and my User/Password is set.

Now, if I want to get a list of db's on a Server, do I just use the IP Address for oCompany.Server?

If that is correct, then I have some issue resulting. I get a messagebox --> Connection to SBO-Common had failed

Does this feel like my connection attempt is still not right? Or does that error message indicate I have troubles elsewhere?

Here is my code for the connection...it fails on --> oRecordSet = oCompany.GetCompanyList

The User and Password fields. How do I know what to use there? I use different UserNames/Passwords for each company when

logging in. Is this Username/Password going to be for some kind of SQL profile?

oCompany = New SAPbobsCOM.Company

'*****************************************

'Initialization Connection Properties

'Manadatory for SQL2005...other may differ

'*****************************************

oCompany.Server = txtServer.Text

oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005

oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English

oCompany.UseTrusted = True

oCompany.UserName = txtUser.Text

oCompany.Password = txtPassword.Text

'**************************

'Create a list of companies

'**************************

oRecordSet = oCompany.GetCompanyList

oCompany.GetLastError(lErrCode, sErrMsg)

If lErrCode <> 0 Then

MsgBox(sErrMsg)

Else

If cmbCompany.Items.Count > 0 Then

cmbCompany.Items.Clear()

End If

Do Until oRecordSet.EoF = True

cmbCompany.Items.Add(oRecordSet.Fields.Item(0).Value)

oRecordSet.MoveNext()

Loop

End If

Thanks,

Ed

AdKerremans
Active Contributor
0 Kudos

Hi Ed,

you did not understand me correctly

UseTrusted must be FALSE

and you must ADD setting for DbUser = "sa" and DbPassword = "..."

Regards,

Ad

Former Member
0 Kudos

Ad,

Your are right, I did not understand. I see what you mean now. I'll try it now.

Thanks,

Ed

Answers (0)