none
Error creating a row in a table RRS feed

  • Question

  • I am using a typed dataset and trying to add a row to a table. See code below.

     

    ProjectDataSet.SPA_SUB_ProjectRow oSubRow = ProjDataSet.SPA_SUB_PROJECT.NewSPA_SUB_PROJECTRow();

    oSubRow.SUB_PROJECT_DESC = "TEST";

     

    When I execute these statements, the first statement creates a SPA_SUB_PROJECT row.

    However, when the second statement executes, I get the following error.

     

    Object reference not set to an instance of an object.

     

    Anyone have any ideas what I may be doing wrong?

     

     

    Thursday, March 27, 2008 7:07 PM

Answers

  • There's nothing obviously wrong in that code. 

     

    You aren't using a BindingSource are you?  The BindingSource updates its data source on its own thread, which creates all kinds of opportunities for invisible cross-thread write operations.  (For instance, calling EndEdit on the BindingSource in the table's RowChanging event, that'll do it.)  Cross-thread write operations on ADO objects cause a lot of mysterious problems, and an apparently-inexplicable NullReferenceException is one of them.

    Friday, March 28, 2008 11:56 PM

All replies

  • There's nothing obviously wrong in that code. 

     

    You aren't using a BindingSource are you?  The BindingSource updates its data source on its own thread, which creates all kinds of opportunities for invisible cross-thread write operations.  (For instance, calling EndEdit on the BindingSource in the table's RowChanging event, that'll do it.)  Cross-thread write operations on ADO objects cause a lot of mysterious problems, and an apparently-inexplicable NullReferenceException is one of them.

    Friday, March 28, 2008 11:56 PM
  • Thanks for thehelp

     

    Tuesday, April 8, 2008 1:44 PM