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

How to Update database from DBDataSoure

I have made a simple form with a Matrix which show the users. I created a DBdataSource, performed a Query on it, thereafter I Loaded the data to the grid with LoadFrom Datasource.

The changes I can easliy write back to the DBDatasource, with the FLush Method. But how do I Update the database?

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 20, 2005 at 07:29 PM

    Hi Francis

    You have to use a DI object. Ever an object like BusinessPartner, Items... or a Usertable in case you use a User Table

    ex to update a business partner :

            Dim oBusinessPartner As SAPbobsCOM.BusinessPartners
            oBusinessPartner = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)
            If oBusinessPartner.GetByKey(oDBDataSource.GetValue("CardCode", oDBDataSource.Offset)) Then
                oBusinessPartner.CardName = oDBDataSource.GetValue("CardName", oDBDataSource.Offset)
                If oBusinessPartner.Update() <> 0 Then
                    MsgBox(SBO_Company.GetLastErrorDescription)
                End If
            End If

    ex to add a new line in a UserTable

            Dim oUsertable As SAPbobsCOM.UserTable
            oUsertable = SBO_Company.UserTables.Item("YourUserTable")
    
            oUsertable.Code = oDBDataSource.GetValue("Code", oDBDataSource.Offset)
            oUsertable.Code = oDBDataSource.GetValue("Name", oDBDataSource.Offset)
            oUsertable.UserFields.Fields.Item("U_YourField").Value = oDBDataSource.GetValue("U_YourField", oDBDataSource.Offset)
            If oUsertable.Add <> 0 Then
                MsgBox(SBO_Company.GetLastErrorDescription)
            End If

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 22, 2005 at 02:31 PM

    I hoped there was a better way Sébastien.

    But that's not your fault.

    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.