cancel
Showing results for 
Search instead for 
Did you mean: 

Insert Into(UDT)

Former Member
0 Kudos

Hello experts, I create UDT table in my [SBO-COMMON. I just want to ask how can I insert record in my table?

I have a edittext in my form.

Try
           
            Dim oEditText As SAPbouiCOM.EditText
            oEditText = oForm.Items.Item("txtCode").Specific

            Dim oComapny As SAPbobsCOM.Company = SBO_Application.Company.GetDICompany
            Dim rsResult As SAPbobsCOM.Recordset = oComapny.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

            rsResult.DoQuery("INSERT INTO [SBO-COMMON]..sports (name) VALUES('" & oEditText.Value & "')")

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

When I click the insert button. The value of my field(name) is NULL. But I actually put a value in my edittext before I click the insert button.

Please help.

Accepted Solutions (1)

Accepted Solutions (1)

former_member682029
Contributor
0 Kudos

Try using a user data souce to retrieve the value from edit text.

Thanks

Former Member
0 Kudos

Hello Anoop,

How should I do that?

former_member682029
Contributor
0 Kudos

You can do the code in loading the form.

sapbouicom.userdatarouce uds1 = form.datasources.userdatasources.add("udsname",...)
oeditText.databind.setbound(true,"","udsname")

Now the edit text is bound with datasource

Now you can use

uds1.valueEx

to read / set the value for the Edit text

Former Member
0 Kudos

Please translate it into VB.NET please.

Should I put that code in Item Event?

Select Case pVal.EventType
                            Case SAPbouiCOM.BoEventTypes.et_FORM_LOAD

former_member682029
Contributor
0 Kudos
Public Sub UsingUserDataSource()

    Dim oForm As SAPbouiCOM.Form
    Dim oEditText As SAPbouiCOM.EditText

    '// Add a form
    Set oForm = SBO_Application.Forms.Add("SimpleForm")

    '// Add a user data source to the form
    oForm.DataSources.UserDataSources.Add "EditSource", dt_SHORT_TEXT, 20

    '//*************************
    '// Adding a Text Edit item
    '//*************************
    Set oEditText = oForm.Items.Add("EditText1", it_EDIT).Specific

    '// Bind the text edit item to the user data source
    oEditText.DataBind.SetBound True, "", "EditSource"

End Sub

Answers (0)