Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NpgsqlCommandBuilder automatic sql commands configuration #179

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

NpgsqlCommandBuilder automatic sql commands configuration #179

czarnul opened this issue Mar 7, 2014 · 4 comments
Assignees
Labels
Milestone

Comments

@czarnul
Copy link

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
Copy link

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 this to the 2.2 milestone Apr 8, 2014
@franciscojunior
Copy link
Member

Nice, @GaryK4 !

I'll work on this issue.

@roji
Copy link
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
CommandBuilder wasn't properly registering to its DataAdapter
events, resulting in bug npgsql#179
@roji
Copy link
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 as completed Jul 26, 2014
roji added a commit that referenced this issue Jul 26, 2014
(cherry picked from commit bee2709)

(From #294)
roji added a commit that referenced this issue Jul 26, 2014
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
Labels
Projects
None yet
Development

No branches or pull requests

4 participants