C# SqlCommandBuilder not performing delete
Im going insane trying to figure this one out.
Im populating a DataTable from my database.
A DataGridView DataSource is set to my DataTable.
I insert, update and delete rows from the DataTable which in turn updates the DataGridView.
Im using the below to update my changes back to the database where i pass in the modified DataTable.
Insert and Update are working but Delete does not remove the deleted rows from the database table.
The myAdapter.DeleteCommand.CommandText is:
private static void updateDatabase(DataTable dt)
SqlDataAdapter myAdapter = new SqlDataAdapter();
SqlCommand myCommand = new SqlCommand("SELECT * from dbo.DisplayList", sqlCon);
SqlCommandBuilder myCommandBuilder = new SqlCommandBuilder(myAdapter);
myAdapter.SelectCommand = myCommand;
myAdapter.InsertCommand = myCommandBuilder.GetInsertCommand();
myAdapter.UpdateCommand = myCommandBuilder.GetUpdateCommand();
myAdapter.DeleteCommand = myCommandBuilder.GetDeleteCommand();
Anyone have any ideas whats wrong with the above or to help investigation how i can find out what the @p values are being converted to?
DELETE FROM [dbo].[DisplayList] WHERE (([PropertyID] = @p1) AND
([DisplayID] = @p2) AND ([DisplayName] = @p3) AND ((@p4 = 1 AND
[TerminalID] IS NULL) OR ([TerminalID] = @p5)))