cancel
Showing results for 
Search instead for 
Did you mean: 

error - object reference is not sent to instance of object

Former Member
0 Kudos

Hi All

i made a form using code , in this form has a one static field nd one edit text field , nd ok , cancel btn, i want to bind this field to usertable @valueo, i using this code for binding,

.................................

oEditText = ((SAPbouiCOM.EditText)(oItem.Specific));

// bind the text edit item to the defined used data source

oDBDataSource2 = oForm.DataSources.DBDataSources.Add ("@VALUE0");

oEditText.DataBind.SetBound(true, "", "EditSource");

oEditText1.DataBind.SetBound(true, "@VALUE0", "U_cl");

so that in this code i have facing a error "Object Reference is not to sent of object"

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Pankaj,

can you please debug the code and tell me in which line exactly it is giving the error.

oEditText = ((SAPbouiCOM.EditText)(oItem.Specific));

in this line you gave Oitem.specific

and also there are two edit text objects( oEditText and oEditText1) make sure that both are pointed to some item in Form

Make sure that you assigned Oitem to Control on the form (oItem=Oform.Items.Item("URITEMUID").

and still you get the error make sure that in your database there is a table called @VALUE0,which contains a column with the name U_cl

ELSE YOU COPY THIS CODE

oItem=oForm.Items.Item("URITEMUID1")

oEditText = ((SAPbouiCOM.EditText)(oItem.Specific));

oItem=oForm.Items.Item("URITEMUID2")

oEditText1 = ((SAPbouiCOM.EditText)(oItem.Specific));

// bind the text edit item to the defined used data source

oDBDataSource2 = oForm.DataSources.DBDataSources.Add ("@VALUE0");

oForm.DataSources.UserDataSources.Add("EditSource", dt_SHORT_TEXT, 10)

oEditText.DataBind.SetBound(true, "", "EditSource");

oEditText1.DataBind.SetBound(true, "@VALUE0", "U_cl");

Hope this helps you

regards

Vishnu

Former Member
0 Kudos

HI vishnu

i used the debug nd find the error this line

oEditText1.DataBind.SetBound(true, "@VALUE0", "U_cl");

error " Object reference is not sent to instance of object'

Former Member
0 Kudos

Hi Pankaj

Then Check is EditText1 is referencing any item or not.

Make sure that the table name you gave(@VALUE0) exists in your database and the column name U_cl exists in that table.These are Case Sensitive here in the Quotes

Regards

Vishnu

Answers (2)

Answers (2)

Former Member
0 Kudos

Pankaj, did you point oEditText1 to an object? Your code here doesn't include that. That's probably it.

Former Member
0 Kudos

Hi Pankaj,

This line may be causing you the problem

oEditText.DataBind.SetBound(true, "", "EditSource");

Comment the above line,only one datasource is enough to bind to a control (either dbdatasource or userdatasource)

OR

Have you added a user datasoure with name EditSource Else

add this line and then try

oForm.DataSources.UserDataSources.Add("EditSource", dt_SHORT_TEXT, 10)

Hope this helps

regards

Vishnu

Former Member
0 Kudos

hi vishnu

i comment the this line

oEditText.DataBind.SetBound(true, "", "EditSource");

but i got the same error

object reference is not sent to instance of object

so help me.