Skip to Content
0
Former Member
Jul 15, 2014 at 05:22 AM

"No Server Defined" in SDK DI Samples

17 Views

Hi everyone.I'm new to SAP B1 like everyone i started learning by practicing the SDK Samples.I'm trying to execute the basic operations Sample but when i'm pressing the "Get Company List" button it is showing a message Box "No Server Found".I'm using SAP 2007 B & Visual Studio 2005.please tell me the solution.

===============> This code is from Choose Company Class

Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click

'// setting the rest of the mandatory properties

oCompany.Server = "(local)"

oCompany.UserName = "manager"

oCompany.Password = "manager"

oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005

'oCompany.CompanyDB = Combo1.Text

'oCompany.UserName = Text1.Text

'oCompany.Password = Text2.Text

'// Connecting to a company DB

lRetCode = oCompany.Connect()

If lRetCode <> 0 Then

oCompany.GetLastError(lErrCode, sErrMsg)

MsgBox("Connection Failed - " & sErrMsg, MsgBoxStyle.Exclamation, "Default Connection Failed")

Else

MsgBox("Connected to " & oCompany.CompanyName)

Me.Text = Me.Text & ": Connected"

' Disable controls

'Label1.Enabled = False

' Label2.Enabled = False

'Label3.Enabled = False

'Combo1.Enabled = False

' Text1.Enabled = False

' Text2.Enabled = False

' Command1.Enabled = False

' cmbDBType.Enabled = False

' cmdGetCompanyList.Enabled = False

End If

End Sub

Private Sub cmdGetCompanyList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetCompanyList.Click

Dim i As Integer ' to be used as an index

oCompany = New SAPbobsCOM.Company

'oCompany.DbServerType = cmbDBType.SelectedIndex + 1

oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005

'// once the Server property of the Company is set

'// we may query for a list of companies to choos from

'// this method returns a Recordset object

Try

oRecordSet = oCompany.GetCompanyList

'oRecordSet.Fields.Item(0).Value("")

'// Use GetLastError method directly after a function

'// which doesn't have a return code

'// you may also use the On Error GoTo.

'// functions with no return codes throws exceptions

oCompany.GetLastError(lErrCode, sErrMsg)

If lErrCode <> 0 Then

MsgBox(sErrMsg)

Else

If oCompany.Connected = False Then

'// Load the available company DB names to the combo box

'// the returned Recordset containds 4 fields:

'// dbName - represents the database name

'// cmpName - represents the company name

'// versStr - represents the version number of the company database

'// dbUser - represents the database owner

'// we are interested in the first filed (mandatory property)

'// Clear the company list

Combo1.Items.Clear()

'// Go through the Recordset and extract the dbname

Do Until oRecordSet.EoF = True

'// add the value of the first field of the Recordset

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

'// move the record pointer to the next row

oRecordSet.MoveNext()

Loop

' Enable controls

Label1.Enabled = True

Label2.Enabled = True

Label3.Enabled = True

Combo1.Enabled = True

Text1.Enabled = True

Text2.Enabled = True

Command1.Enabled = True

End If

End If

If oCompany.Connected = True Then

'// if the company object is allreay connected to a DB

'// you must first Disconnect it before connecting it

'// to a different DB

'// bare in mind that by disconnecting the company object

'// you lose all of the properties (Server, Language)

Command1.Enabled = False

Combo1.SelectedText = oCompany.CompanyDB

Text1.Text = oCompany.UserName

Text2.Text = oCompany.Password

Me.Text = Me.Text & ": Connected"

End If

Catch ex As Exception

MsgBox(ex.Message)

InitializeCompany()

End Try

End Sub

End Class

==============> globals.vb class

Module globals_Renamed

Public Sub InitializeCompany()

'// Initialize the Company Object.

'// Create a new company object

oCompany = New SAPbobsCOM.Company

oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005

'// Set the mandatory properties for the connection to the database.

'// here I bring only 2 of the 5 mandatory fields.

'// To use a remote Db Server enter his name instead of the string "(local)"

'// This string is used to work on a DB installed on your local machine

'// the other mandatory fields are CompanyDB, UserName and Password

'// I am setting those fields in the ChooseCompany Form

oCompany.Server = "(local)"

oCompany.language = SAPbobsCOM.BoSuppLangs.ln_English

oCompany.CompanyDB = "SBODemoIN"

oCompany.UserName = "manager"

oCompany.Password = "manager"

'// Use Windows authentication for database server.

'// True for NT server authentication,

'// False for database server authentication.

oCompany.UseTrusted = True

End Sub