I have this situation where I need to modify the insert command after is generated by the sqlcommandbuilder, and I need to do this to get the scope_identity after the insert. Part of the code is :
adapterClients = new SqlDataAdapter (cmdClients, connString);
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder (adapterClients);
adapterClients.Fill (dataSet, "Clients");
adapterClients.InsertCommand.CommandText += "; select ClientID = SCOPE_IDENTITY()";
adapterClients.InsertCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord;
I get a null exception on adapterClients.InsertCommand.