I can find it, why can't my code?

Discussion in 'ASP .Net Datagrid Control' started by PaulNaude, Oct 12, 2005.

  1. PaulNaude

    PaulNaude Guest

    I have a problem deleting a record from a table with 3 primary keys, in code.
    I get the values of the primary keys from my datagrid displaying the record
    to be deleted as follows:
    ....
    findTheseVals(0) = DataGrid4.Item(u, 0) 'First column and unique primary key
    (no duplicates allowed)
    findTheseVals(1) = DataGrid4.Item(u, 1) 'Second column and primary key
    (duplicates ok)
    findTheseVals(2) = DataGrid4.Item(u, 2) 'Third column and primary key
    (duplicates ok)
    ....

    Then, to delete the record from the table, I use

    DataSet11.Tables("Equipment").Rows.Find(findTheseVals).Delete()

    but get the following error:

    An unhandled exception of type 'System.NullReferenceException' occurred in
    App.exe
    Additional information: Object reference not set to an instance of an object.

    i.e. this record was not found, although I can physically see it in the table.

    I checked the populated values of findTheseVals and it matches my primary
    key values (and types) in the database table exactly.
    The column orders in the dataAdapter, datagrid and database table are
    identical.
    I checked that the table referenced is exactly the same as the one
    referenced by the datagrid etc.

    When I manually delete the row from my datagrid, the record is correctly
    deleted from the database.

    What am I missing here?
    PaulNaude, Oct 12, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    876
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,805
    Smokey Grindel
    Dec 2, 2006
  3. Wybo Dekker
    Replies:
    1
    Views:
    350
    Yukihiro Matsumoto
    Nov 15, 2005
  4. vdvorkin
    Replies:
    0
    Views:
    398
    vdvorkin
    Feb 10, 2011
  5. vdvorkin
    Replies:
    3
    Views:
    806
    vdvorkin
    Feb 14, 2011
Loading...

Share This Page