UPDATE [dbo].[gst_pass] SET [pass_no] = @pass_no, -- BTW, this is a PK in that table [guest_no] = @guest_no, [masterpass] = @masterpass, [swipe_no] = @swipe_no, [addit_no] = @addit_no, [wtp_no] = @wtp_no, [rfserial] = @rfserial, [additchar1] = @additchar1, [additchar2] = @additchar2, [addit_no2] = @addit_no2, [addit_no3] = @addit_no3, [val_parent] = @val_parent, [valprnttyp] = @valprnttyp, [last_use] = @last_use, [printcount] = @printcount, etc. for about 30 more columns [a_maxqty6] = @a_maxqty6, [a_trklqty6] = @a_trklqty6, [a_names] = @a_names, [mod_op] = @mod_op, [mod_sp] = @mod_sp, [cc_swipe] = @cc_swipe, [pin] = @pin WHERE (([pass_no] = @Original_pass_no))-- where is fixed
public Boolean UpdateRows(Boolean generateCommands = false) { Boolean results = false; try { if (generateCommands) { SqlCommandBuilder builder = new SqlCommandBuilder(adapter); builder.ConflictOption = ConflictOption.OverwriteChanges; builder.SetAllValues = false; // Set only changed values adapter.UpdateCommand = builder.GetUpdateCommand(true); } adapter.Update(this.table); results = true; } catch (Exception ex) { results = false; Logging.LogFormat(2, ex.Message); // at least log the problem } return results; }and I added
protected Boolean ProcessDataTable(SqlCommand toSqlCommand) { Boolean results = false; try { this.table = new DataTable(); this.adapter = new SqlDataAdapter(toSqlCommand); this.adapter.SelectCommand = toSqlCommand; this.adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; // Generate PK information this.adapter.Fill(this.table); results = true; } catch (Exception ex) { results = false; Logging.LogFormat(2, ex.Message); // at least log the problem } return results; }Do you see what is missing and why it didn't work for me?