cancel
Showing results for 
Search instead for 
Did you mean: 

-146 Tenant not exists

KMTech
Newcomer
0 Kudos

We've encountered an error "-146 - Tenant not exists" while attempting to connect to SAP through the DI API. Our setup involves two databases: production and sandbox. Upon investigation, we've noted that this error occurs only when switching databases.

To elaborate, if we initially connect to the production database, we can establish the connection successfully. However, upon switching to the sandbox database, we encounter the "-146 - Tenant not exists" error. Similarly, if we first connect to the sandbox database, the connection is successful, but switching to the production database results in the same error.

We have attached the DI API log for reference. 

Company::_SetLastError error code:-146, error msg: Tenant is not exist, error context: 
After  Command "Company:Connect", InterfaceID="00000274B573C4C0" Output Type="long", Output Value = "-146" 
Before Command "Company:GetLastErrorCode", InterfaceID="00000274B573C4C0"  
After  Command "Company:GetLastErrorCode", InterfaceID="00000274B573C4C0" Output Type="long", Output Value = "-146" 
Before Command "Company:GetLastErrorDescription", InterfaceID="00000274B573C4C0"  
After  Command "Company:GetLastErrorDescription", InterfaceID="00000274B573C4C0" Output Type="String", Output Value = "Tenant is not exist" 
Before GetProperty Interface="Company" InterfaceID="-1250704192" PropertyName="Connected" value=""
After  GetProperty Interface="Company" InterfaceID="-1250704192" PropertyName="Connected" value="0"
Before GetProperty Interface="Company" InterfaceID="-1250704192" PropertyName="Connected" value=""
After  GetProperty Interface="Company" InterfaceID="-1250704192" PropertyName="Connected" value="0"
View Entire Topic
nidhisingh14
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear KMTech

User need to use domain user  and password with B1 Cloud environment and please make sure that domain user should be assigned to a tenant in CCC.

Below samplecode worked for us in our test environment for login to company DB through DI API.

oCompany.Server = "ServerName"
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008
oCompany.CompanyDB = "SBODemoDE"
oCompany.UserName = "GLOBAL\userid"
oCompany.Password = "********”
lRetCode = oCompany.Connect()

If lRetCode <> 0 Then 'if the connection failed
oCompany.GetLastError(lErrCode, sErrMsg)
MsgBox("Connection Failed - " & sErrMsg, MsgBoxStyle.Exclamation, "Default Connection Failed")
End If
If oCompany.Connected Then ' if connected
MsgBox("ok")
End If

Hope it helps.

Thank You.

Kind Regards
Nidhi singh
SAP Business One Support