Skip to content

NpgsqlCommandBuilder automatic sql commands configuration #179

Closed

Description

@czarnul

When i use NpgsqlCommandBuilder with NpgsqlDataAdapter i always want to configure update,insert,delete commands. Earlier when i used Npgsql 2.0.1.0 version this code works fine:

DataTable t = new DataTable();            
NpgsqlConnection con = new NpgsqlConnection("some connection string");
con.Open();
NpgsqlDataAdapter adp = new NpgsqlDataAdapter("select id,description from device", con); //where id is primary key
adp.Fill(t);
NpgsqlCommandBuilder bld = new NpgsqlCommandBuilder(adp);
DataRow r = t.NewRow();
r[0] = 300001;
t.Rows.Add(r);
DataRow[] rows = new DataRow[1];
rows[0] = r;
adp.Update(rows);
con.Close();

Now with Npgsql 2.0.14.3 this code doesn`t work and all our projects must be changed because we have

InvalidOperationException

Now we must everywhere where we use Adapter and Builder before adp.Update() do this:

adp.InsertCommand = bld.GetInsertCommand();
adp.UpdateCommand = bld.GetUpdateCommand();
adp.DeleteCommand = bld.GetDeleteCommand();

Activity

  1. GaryK4 commented on Apr 8, 2014

    @GaryK4

    I am testing PostreSQL coming from MySql and I got this same error. At least, I know how to work around the problem now until it is fixed. In my case it was also bound to a Datagridview.

  2. added this to the milestone on Apr 8, 2014
  3. franciscojunior commented on Apr 8, 2014

    @franciscojunior
    Member

    Nice, @GaryK4 !

    I'll work on this issue.

  4. self-assigned this
    on Jul 21, 2014
  5. roji commented on Jul 21, 2014

    @roji
    Member

    @franciscojunior, I'll take a look at this in the coming days...

  6. roji commented on Jul 26, 2014

    @roji
    Member

    @czarnul, @neonsnowball, this bug has been fixed in master. You can download the latest binaries from our build server and confirm.

  7. added theissue type on Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions