cancel
Showing results for 
Search instead for 
Did you mean: 

Error Binding Data !

Former Member
0 Kudos

Hi al,

I have a scenario, and hope u help:

I created a table: Table name: tblIncentive, Object: Document

I use UDF to create the field for that table: DocEntry, DocNum, etc., U_level1, U_Level2, U_Level3. (The fields of tblIncentive)

And then,

I created a form and binding data for the fields

Example: Binding for U_Level1 field

oItem = oForm.Items.Add("txtLevel1", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 60

oItem.Height = 14

oItem.LinkTo = "lblLevel1"

oEditText = oItem.Specific

oEditText.DataBind.SetBound(True, "@TBLINCENTIVE", "U_Level1")

But its error:

The message: table not found [131-183]

System.Runtime.InteropServices.COMException was unhandled

ErrorCode=-2004

Message="Table not found [131-183]"

Source=""

StackTrace:

at SAPbouiCOM.DataBindClass.SetBound(Boolean Bound, String TableName, String Alias)

at AddTextbox.AddComponents.CreateForm() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\AddTextbox\AddTextbox\AddComponents.vb:line 395

at AddTextbox.AddComponents.SetApplication() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\AddTextbox\AddTextbox\AddComponents.vb:line 19

at AddTextbox.AddComponents..ctor() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\AddTextbox\AddTextbox\AddComponents.vb:line 22

at AddTextbox.Main.Main() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\AddTextbox\AddTextbox\Main.vb:line 6

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

Plz help me !

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi..

U designed form through code or screen painter.

screen painter means.

select item go to data bound select true that's all.

Regards..

Billa 2007

Former Member
0 Kudos

Hi,

I use code to create form.

that code:

Private Sub CreateForm()

'SetApplication()

Dim oItem As SAPbouiCOM.Item

Dim oButton As SAPbouiCOM.Button

Dim oStaticText As SAPbouiCOM.StaticText

Dim oEditText As SAPbouiCOM.EditText

Dim oComboBox As SAPbouiCOM.ComboBox

Dim cp As SAPbouiCOM.FormCreationParams

' Create the form

cp = oApp.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

cp.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed

cp.FormType = "Incentive"

cp.UniqueID = "Incentive"

oForm = oApp.Forms.AddEx(cp)

oForm.ClientHeight = 190

oForm.ClientWidth = 260

oForm.Visible = True

bIncentive = True

'// Adding Items to the form

'// Adding an Ok button

oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Left = 10

oItem.Width = 60

oItem.Top = 160

oItem.Height = 19

oButton = oItem.Specific

oButton.Caption = "Ok"

'// Adding a Cancel button

oItem = oForm.Items.Add("2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Left = 75

oItem.Width = 60

oItem.Top = 160

oItem.Height = 19

oButton = oItem.Specific

oButton.Caption = "Cancel"

'// Adding a Static Text item

oItem = oForm.Items.Add("Incentives", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 148

oItem.Top = 15

oItem.Height = 14

oItem.LinkTo = "txtIncen"

oStaticText = oItem.Specific

oStaticText.Caption = "Incentives: "

'// Adding another Static Text item

oItem = oForm.Items.Add("lblLevel1", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 148

oItem.Top = 60

oItem.Height = 14

oDBDataSource = oForm.DataSources.DBDataSources.Add("@TBLINCENTIVE")

oItem.LinkTo = "txtLevel1"

oStaticText = oItem.Specific

oStaticText.Caption = "Level 1"

'' //Add a edit text item

oItem = oForm.Items.Add("txtLevel1", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 60

oItem.Height = 14

oItem.LinkTo = "lblLevel1"

oEditText = oItem.Specific

oEditText.DataBind.SetBound(True, "@TBLINCENTIVE", "U_Level1")

' // Add level 2

oItem = oForm.Items.Add("lblLevel2", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 148

oItem.Top = 80

oItem.Height = 14

oItem.LinkTo = "txtLevel"

oStaticText = oItem.Specific

oStaticText.Caption = "Level 2"

'' //Add a edit text item

oItem = oForm.Items.Add("txtLevel2", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 80

oItem.Height = 14

oItem.LinkTo = "lblLevel2"

oEditText = oItem.Specific

oEditText.DataBind.SetBound(True, "@TBLINCENTIVE", "U_Level2")

' // Add level 3

oItem = oForm.Items.Add("lblLevel3", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 148

oItem.Top = 100

oItem.Height = 14

oItem.LinkTo = "txtLevel3"

oStaticText = oItem.Specific

oStaticText.Caption = "Level 3"

'' //Add a edit text item

oItem = oForm.Items.Add("txtLevel3", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 100

oItem.Height = 14

oItem.LinkTo = "lblLevel3"

oEditText = oItem.Specific

oEditText.DataBind.SetBound(True, "@TBLINCENTIVE", "U_Level3")

'// Adding a Combo Box item

oItem = oForm.Items.Add("ComboBox1", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 15

oItem.Height = 14

oItem.DisplayDesc = False

oComboBox = oItem.Specific

oForm.DataSources.UserDataSources.Add("CombSource", SAPbouiCOM.BoDataType.dt_LONG_TEXT, 250)

'// Bind the Combo Box item to the defined used data source

oComboBox.DataBind.SetBound(True, "", "CombSource")

oComboBox.ValidValues.Add("1", "Solar calendar")

oComboBox.ValidValues.Add("2", "30th April")

oComboBox.ValidValues.Add("3", "The labor day")

oComboBox.ValidValues.Add("4", "Lunar calendar (10th March)")

oComboBox.ValidValues.Add("5", "The Indepedent day - 2/9")

oComboBox.ValidValues.Add("6", "Lunar calendar")

oComboBox.ValidValues.Add("7", "The women day")

oComboBox.ValidValues.Add("8", "Company's birthday")

oComboBox.ValidValues.Add("9", "Vietnamese woman's day")

oComboBox.ValidValues.Add("10", "The international Children day")

End Sub

Plz tell me !

Rgds !

Former Member
0 Kudos

Hi..

oDBDataSource = oForm.DataSources.DBDataSources.Add("@TBLINCENTIVE")

Replace Of

oDBDataSource = oForm.DataSources.DBDataSources.Item("@TBLINCENTIVE")

Regards.

Billa 2007

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello hung,

You need to bind the UDO object type to the form

creationPackage.ObjectType = "YouUDO"

Again, UDO Form Generator can do everything for you. : )

Kind Regards

-Yatsea

Former Member
0 Kudos

Hi,

I relaced

oDBDataSource = oForm.DataSources.DBDataSources.Add("@TBLINCENTIVE")

By

oDBDataSource = oForm.DataSources.DBDataSources.Item("@TBLINCENTIVE")

but it's error : Collection - Out of boundaries [66000-34]

Plz help me !

Rgds !

former_member201110
Active Contributor
0 Kudos

Hi,

As Yatsea as stated above, you need to link your form to the UDO you have created. A DBDataSource will not automatically update the database unless the form is linked to a UDO and the field you are binding to is from the UDO's table.

If you prefer to use code to create your form then you need to set the ObjectType property of the FormCreationParams object to the name of your UDO.

If you are using screen painter to create your form then open your srf file in a XML editor (or a text editor like Notepad) and look for the property Object="". This should be in the <Form> node of the XML. Set this property to the name of your UDO. Save the file and try loading the form again.

Kind Regards,

Owen

P.S.


oDBDataSource = oForm.DataSources.DBDataSources.Item("@TBLINCENTIVE")

will cause an error if you have not already set this datasource up in the srf file. This is because it is looking for an existing datasource in the form.

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Hung,

You can't use

oDBDataSource = oForm.DataSources.DBDataSources.Item("@TBLINCENTIVE")

before you add it.

This is not the reason. Did you set the ObjectType for the form? And how is it going on?

Kind Regards

-Yatsea

Former Member
0 Kudos

Hi Yatsea,

I tell u all steps:

- Step 1: I created table @TBLINCENTIVE with fields: DocEntry, DocNum, Period, etc. , U_Level1, U_Level2, U_Level3.

-Step 2 : I wrote this code

Private Sub CreateForm()

'SetApplication()

Dim oItem As SAPbouiCOM.Item

Dim oButton As SAPbouiCOM.Button

Dim oStaticText As SAPbouiCOM.StaticText

Dim oEditText As SAPbouiCOM.EditText

Dim oComboBox As SAPbouiCOM.ComboBox

Dim cp As SAPbouiCOM.FormCreationParams

' Create the form

cp = oApp.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

cp.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed

cp.FormType = "Incentive"

cp.UniqueID = "Incentive"

oForm = oApp.Forms.AddEx(cp)

oForm.ClientHeight = 190

oForm.ClientWidth = 260

oForm.Visible = True

bIncentive = True

'// Adding Items to the form

'// Adding an Ok button

oItem = oForm.Items.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Left = 10

oItem.Width = 60

oItem.Top = 160

oItem.Height = 19

oButton = oItem.Specific

oButton.Caption = "Ok"

'// Adding a Cancel button

oItem = oForm.Items.Add("2", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

oItem.Left = 75

oItem.Width = 60

oItem.Top = 160

oItem.Height = 19

oButton = oItem.Specific

oButton.Caption = "Cancel"

'// Adding a Static Text item

oItem = oForm.Items.Add("Incentives", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 148

oItem.Top = 15

oItem.Height = 14

oItem.LinkTo = "txtIncen"

oStaticText = oItem.Specific

oStaticText.Caption = "Incentives: "

'// Adding another Static Text item

oItem = oForm.Items.Add("lblLevel1", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 148

oItem.Top = 60

oItem.Height = 14

oDBDataSource = oForm.DataSources.DBDataSources.Add("@TBLINCENTIVE")

oItem.LinkTo = "txtLevel1"

oStaticText = oItem.Specific

oStaticText.Caption = "Level 1"

'' //Add a edit text item

oItem = oForm.Items.Add("txtLevel1", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 60

oItem.Height = 14

oItem.LinkTo = "lblLevel1"

oEditText = oItem.Specific

oEditText.DataBind.SetBound(True, "@TBLINCENTIVE", "U_Level1")

' // Add level 2

oItem = oForm.Items.Add("lblLevel2", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 148

oItem.Top = 80

oItem.Height = 14

oItem.LinkTo = "txtLevel"

oStaticText = oItem.Specific

oStaticText.Caption = "Level 2"

'' //Add a edit text item

oItem = oForm.Items.Add("txtLevel2", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 80

oItem.Height = 14

oItem.LinkTo = "lblLevel2"

oEditText = oItem.Specific

oEditText.DataBind.SetBound(True, "@TBLINCENTIVE", "U_Level2")

' // Add level 3

oItem = oForm.Items.Add("lblLevel3", SAPbouiCOM.BoFormItemTypes.it_STATIC)

oItem.Left = 7

oItem.Width = 148

oItem.Top = 100

oItem.Height = 14

oItem.LinkTo = "txtLevel3"

oStaticText = oItem.Specific

oStaticText.Caption = "Level 3"

'' //Add a edit text item

oItem = oForm.Items.Add("txtLevel3", SAPbouiCOM.BoFormItemTypes.it_EDIT)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 100

oItem.Height = 14

oItem.LinkTo = "lblLevel3"

oEditText = oItem.Specific

oEditText.DataBind.SetBound(True, "@TBLINCENTIVE", "U_Level3")

'// Adding a Combo Box item

oItem = oForm.Items.Add("ComboBox1", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)

oItem.Left = 65

oItem.Width = 148

oItem.Top = 15

oItem.Height = 14

oItem.DisplayDesc = False

oComboBox = oItem.Specific

oForm.DataSources.UserDataSources.Add("CombSource", SAPbouiCOM.BoDataType.dt_LONG_TEXT, 250)

'// Bind the Combo Box item to the defined used data source

oComboBox.DataBind.SetBound(True, "", "CombSource")

oComboBox.ValidValues.Add("1", "Solar calendar")

oComboBox.ValidValues.Add("2", "30th April")

oComboBox.ValidValues.Add("3", "The labor day")

oComboBox.ValidValues.Add("4", "Lunar calendar (10th March)")

oComboBox.ValidValues.Add("5", "The Indepedent day - 2/9")

oComboBox.ValidValues.Add("6", "Lunar calendar")

oComboBox.ValidValues.Add("7", "The women day")

oComboBox.ValidValues.Add("8", "Company's birthday")

oComboBox.ValidValues.Add("9", "Vietnamese woman's day")

oComboBox.ValidValues.Add("10", "The international Children day")

End Sub

-When i start (F5), I can display that form, but it doesn't update to database (update to @TBLINCENTIVE)

-When the system display the form after clicking the OK or Cancel button the form jz refresh and display the same not automatic close or Add in the information after click OK button.

How can i do? (Plz see code)

former_member201110
Active Contributor
0 Kudos

Hi

Change the code


cp.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed
cp.FormType = "Incentive"
cp.UniqueID = "Incentive"

to


cp.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Fixed
cp.FormType = "Incentive"
cp.UniqueID = "Incentive"
cp.ObjectType = "YOUR_UDO_ID"

where YOUR_UDO_ID should be the name of your UDO when you registered your table as a UDO.

Kind Regards,

Owen

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Hung,

Please Register a UDO for this UDT through:

Tools=>Configuration Tools=>Object Registration Wizard

Or refer to the pps to see how to register UDO <<C:\Program Files\SAP\SAP Business One SDK\Help\Creating a UDO of document type.pps>>

then set the UDO type to your form.

Kind Regards

-Yatsea

Former Member
0 Kudos

Hi Yatsea & Owen,

That problem is solved ! Thank so much !

-When the system display the form after clicking the OK or Cancel button the form jz refresh and display the same not automatic close or Add in the information after click OK button.

And I add form to Menu:

Private Sub SetApplication()

Dim SboGuiApi As SAPbouiCOM.SboGuiApi

Dim sConnectionString As String

SboGuiApi = New SAPbouiCOM.SboGuiApi

sConnectionString = Environment.GetCommandLineArgs.GetValue(1)

'Connect to a running SBO Application

SboGuiApi.Connect(sConnectionString)

'Get an initialized application object

oApp = SboGuiApi.GetApplication()

CreateForm()

Addmenu()

End Sub

Public Sub AddMenu()

'Add Menu

Dim oMenu As SAPbouiCOM.Menus = oApp.Menus

Dim oMenuItem As SAPbouiCOM.MenuItem

oMenuItem = oApp.Menus.Item("43544")

Dim oCreationPackage As SAPbouiCOM.MenuCreationParams

oCreationPackage = oApp.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)

sPath = System.Windows.Forms.Application.StartupPath()

If oApp.Menus.Exists("IncentiveForm") Then

oApp.Menus.RemoveEx("IncentiveForm")

End If

oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING

oCreationPackage.UniqueID = "Code"

oCreationPackage.String = "Incentive"

oCreationPackage.Enabled = True

oCreationPackage.Checked = True

oCreationPackage.Position = 5 'starts from 0

oMenu = oMenuItem.SubMenus

Try

oMenu.AddEx(oCreationPackage)

Catch ex As Exception

MsgBox("Menu Already Exists")

End Try

End Sub

When I press (F5) it's the same error !

Plz !

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Hung,

You may try not to set the caption for the ok and cancel button.

'Add Ok button UID = 1
        Dim oItems As SAPbouiCOM.Items = oForm.Items
        oItem = oItems.Add("1", SAPbouiCOM.BoFormItemTypes.it_BUTTON)
        oItem.Top = 100
        oItem.Left = 10
        oItem.Width = 70
        oItem.Height = 19
        oButton = oItem.Specific
        'oButton.Caption = "&Ok"

Kind Regards

-Yatsea

Former Member
0 Kudos

Hi Yatsea,

When the system display the form after clicking the OK or Cancel button the form jz refresh and display the same not automatic close or Add in the information after click OK button.

Do u know, wat is the problem?

Former Member
0 Kudos

Hi Yatsea,

I try to set caption for Ok button, Cancel button. But when the system display the form after clicking the OK or Cancel button the form jz refresh and display the same not automatic close after click OK button.

Plz help !

Answers (2)

Answers (2)

YatseaLi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Hung,

Before you bind the fields, did add the db datasource?

Set oDBDataSource = oForm.DataSources.DBDataSources.Add("OCRD")

or you can refer to the sample as Bila2007 mentioned.

If you are using UDO, you use UDO Form Generator to create form XML. You don't need to code the form.

UDO Form Generator is under: (after installing B1DE)

Start=>All Programs=>SAP Business One=>Development Tools=>SAP Business One UDO Form Generator

Kind Regards

-Yatsea

Former Member
0 Kudos

Hi Yatsea,

How r u?

Thks for help !

I create a form and inside the form got new textbox, label and 2 buttons ( Ok+ Cancel), when the system display the form after clicking the OK or Cancel button the form jz refresh and display the same not automatic close or Add in the information after click OK button. How can i do?

And, i try to use

h1oDBDataSource=oForm.DataSources.DBDataSources.Add("@TBLINCENTIVE")

It doesn't update to database (not update to @TBLINCENTIVE table)

Plz help me !

Former Member
0 Kudos

Hi...

see this Example

:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\06.MatrixAndDataSources\2003

Regards...

Billa 2007

Former Member
0 Kudos

Hi,

I try, but i don't know what is the reaon