G
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?
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?