Skip to Content
author's profile photo Former Member
Former Member

Help , How to get data from database using recordset with UI API

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Jun 08, 2007 at 06:59 AM

    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
    

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 08, 2007 at 05:14 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 08, 2007 at 07:34 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.