locked
Error when removing a datacolumn RRS feed

  • Question

  • I am trying to remove a column from my datatable. I am receiving an error "System.NullReferenceException  :  System.Data  :  Object reference not set to an instance of an object." The odd thing is, when I run the code in my Command Window, it executes with no error.

    If Me.Dataset1.Table1.Columns.Contains("SearchString") = True Then
         Me.Dataset1.Table1.Columns("SearchString").Expression = ""
         Me.Dataset1.Table1.Columns.Remove("SearchString") <-- this line produces the error.
    End If


    Any help would be greatly appreciated!
    Monday, August 13, 2007 2:56 PM

All replies

  • Hi NINA!

     

    Try this.

     

    Me.Dataset1.Table1.Columns.Remove("SearchString")

     

    This might solve your problem.

     

    Regards,

    Wasif Ahmad

    Monday, August 13, 2007 3:23 PM
  • Hi, and thanks for your response.
    Your response is actually what I am doing.
    I was replacing the actual dataset name and table name from my code with generic names, to make it easier for others to read, and I forgot to replace one part. I edited the original post now. But as you see, that still does not work.

    Thank you.
    Monday, August 13, 2007 3:55 PM
  • Dear NINA!

     

    Can you please send complete code so that i can debug it here and tell you the solution.

     

    Regards,

    Wasif Ahmad

    Monday, August 13, 2007 4:42 PM