NpgsqlCommandBuilder automatic sql commands configuration #179

Closed
czarnul opened this Issue Mar 7, 2014 · 4 comments

Comments

Projects
None yet
4 participants
@czarnul

czarnul commented Mar 7, 2014

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();
@GaryK4

This comment has been minimized.

Show comment
Hide comment
@GaryK4

GaryK4 Apr 8, 2014

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.

GaryK4 commented Apr 8, 2014

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.

@franciscojunior franciscojunior added the bug label Apr 8, 2014

@franciscojunior franciscojunior added this to the 2.2 milestone Apr 8, 2014

@franciscojunior

This comment has been minimized.

Show comment
Hide comment
@franciscojunior

franciscojunior Apr 8, 2014

Member

Nice, @GaryK4 !

I'll work on this issue.

Member

franciscojunior commented Apr 8, 2014

Nice, @GaryK4 !

I'll work on this issue.

roji pushed a commit to roji/Npgsql that referenced this issue Jul 21, 2014

@roji roji self-assigned this Jul 21, 2014

@roji

This comment has been minimized.

Show comment
Hide comment
@roji

roji Jul 21, 2014

Member

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

Member

roji commented Jul 21, 2014

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

roji added a commit to roji/Npgsql that referenced this issue Jul 25, 2014

roji added a commit to roji/Npgsql that referenced this issue Jul 25, 2014

Fix CommandBuilder event registration
CommandBuilder wasn't properly registering to its DataAdapter
events, resulting in bug #179
@roji

This comment has been minimized.

Show comment
Hide comment
@roji

roji Jul 26, 2014

Member

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

Member

roji commented Jul 26, 2014

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

@roji roji closed this Jul 26, 2014

roji added a commit that referenced this issue Jul 26, 2014

Unit test to reproduce #179
(cherry picked from commit bee2709)

(From #294)

roji added a commit that referenced this issue Jul 26, 2014

Fix CommandBuilder event registration
CommandBuilder wasn't properly registering to its DataAdapter
events, resulting in bug #179

(cherry picked from commit 9940744)

(From #294)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment