I have a simple form that has 2 columns. I have an InsertCommand and DeleteCommand. What I'm want to do is you insert/delete data and then the Update does the dirty work on one button as opposed to 2 or 3 buttons.
The Insert is fine, the delete never works. I think the problem is that the table doesn't have a primary key, but I'm not sure. The other issue on a delete statement: What works better, DeleteCommand or ExecuteNonQuery? They both do the same thing, but since that isn't working, I'm not sure.
SqlCommand cmd = new SqlCommand("Insert into door(foo, tool) values (@dd, @tool)", conct);int nRo = dg.CurrentCell.RowIndex;
cmd.Parameters.AddWithValue("@dd", dg.Rows[nRo].Cells[0].Value);
cmd.Parameters.AddWithValue("@tool", dg.Rows[nRo].Cells[1].Value);
ad.InsertCommand = cmd;
SqlCommand cmd = new SqlCommand("Delete from door where foo=@ddd", conct);
cmd.Parameters.AddWithValue("@ddd", dg.Rows[nRo].Cells[0].Value);
cmd.Parameters["@ddd"].SourceVersion=DataRowVersion.Original;
cmd.Parameters["@ddd"].SourceColumn="foo";
dataT.AcceptChanges();
ad.DeleteCommand = cmd;
ad.Update(dataT);
Thanks, you've helped me so many times..