When I use a SqlCommandBuilder to push updates/inserts/deletes to the server do I need to call .GetUpdateCommand()
, .GetInsertCommand()
, and .GetDeleteCommand()
?
using (var adapter = new SqlDataAdapter("select * from MyTable", _connection))
using (var builder = new SqlCommandBuilder(adapter))
{
adapter.Fill(dt);
//Magic happens
builder.GetUpdateCommand(); //is this line necessary
builder.GetInsertCommand(); //is this line necessary
adapter.Update(dt);
}
I have seen conflicting examples on what is the correct procedure to do. I know it works without it but I did not know if it did something special behind the scenes. Is this necessary or is it cargo cult programming?