on 06-08-2007 6:04 AM
I want to get a data from database
when I want to create recordset i notice that UI API didn't has record set
so I created recordset using DI API (SAPbobscom.recordset and SAPbobscom.company)
======================================================
Dim oCompanyUI As SAPbouiCOM.Company <<UI API
Dim oRecSet As New SAPbobsCOM.Recordset << DI API
Dim oCompanyDI As New SAPbobsCOM.Company << DI API
'=====================================================
oCompanyDI.Connect
Set oRecSet = oCompanyDI.GetBusinessObject(BoRecordset)
oRecSet.DoQuery ("SELECT T0.CardCode, T0.CardName FROM OCRD T0")
SBO_Application.MessageBox oRecSet.Fields.Item(1).Value
======================================================
but I got an error it said "you are not connected to company"
I'm really don't have an idea about how to get a data from using UI API (exp I want to get a date or costumer code)
can someone help me please, I really need it
Thanks
Try to add this code instead of the "oCompanyDI.Connect" line :
Dim sCookie as string
Dim sConnectionContext as string
Dim Ret as integer
sCookie = oCompanyDI.GetContextCookie
sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie)
If oCompanyDI.Connected Then oCompanyDI.Disconnect()
Ret = oCompanyDI.SetSboLoginContext(sConnectionContext)
If Ret <> 0 Then
SBO_Application.MessageBox("Cannot set login context. Connection failed !")
Else
Ret = oCompanyDI.Connect
If Ret<>0 Then SBO_Application.MessageBox("Connection failed !")
End If
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you need a single sign on
Dim oDICompany As SAPbobsCOM.Company
Dim sCookie As String
Dim sConnStr As String
Dim ret As Integer
oDICompany = New SAPbobsCOM.Company
sCookie = oDICompany.GetContextCookie
sConnStr = SBO_Application.Company.GetConnectionContext(sCookie)
If oDICompany.Connected Then
oDICompany.Disconnect()
End If
ret = oDICompany.SetSboLoginContext(sConnStr)
If Not ret = 0 Then
SBO_Application.MessageBox("set Login Context failed!")
Exit Sub
End If
ret = oDICompany.Connect()
If Not ret = 0 Then
SBO_Application.MessageBox("Company Connect failed!")
End If
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Acumen,
I assume you want to do this from an addon, so you als must connect to SBO using the DI.
If you look int the SDK help and/or samples UIDIBasicApp in C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI DI\VB.NET\UIDIBasicApp
you will find the solution for your problem.
Regards
Ad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.