PgFoundry Logo
     Advanced search
Log In
New Account
  
 
Home My Page Project Tree Project Openings Npgsql .Net Data Provider for Postgresql
 
 
 
 
Summary Forums Tracker Lists Tasks Docs Surveys News SCM Files
 
 

Bugs: Browse | Admin

[#1010379] NpgsqlDataAdapter.Update - Return value is wrong

Date:
2008-04-18 14:39
Priority:
3
Submitted By:
Christian Holzner (christianh)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Npgsql Version:
 
Summary:
NpgsqlDataAdapter.Update - Return value is wrong

Detailed description
Hello,

the return value of the NpgsqlDataAdapter.Update(row) method always returns 1, even if the row isn't updated in the
database.

Sincerely


Holzner Christian

Please login

Followup

Message
Date: 2009-04-01 15:23
Sender: Francisco Figueiredo jr. 

Hi, Christian!

I just committed a fix for this problem and now Npgsql correctly
returns 0 rows affected which makes ado.net throw the
dbconcurrencyexception.

Please, get latest cvs version and give it a try.

Let me know if it worked for you.

Thanks in advance
Date: 2008-09-07 22:48
Sender: Francisco Figueiredo jr. 


Hi, from what I saw, I think Npgsql is not checking that the
update wasn't successful and doesn't throw the dbconcurrency
exception. We are checking that but I don't know if it will be
fixed for rc2 release.

Sorry for that.
Date: 2008-05-14 05:52
Sender: Christian Holzner

Now I ran some tests again (source code below):
beta2: works how it should
beta3: not works how it should
beta4: not works how it should

My client systems:
German WXP SP2
Microsoft Visual Studio 2005
Microsoft .Net Framework 2.0 SP1
Npgsql2.0beta2
Npgsql2.0beta3-bin-ms.net2.0
Npgsql2.0beta4-bin-ms.net2.0

My server systems:
German WXP SP2
PostgreSQL 8.3.1


Source code:
  Private Sub Form1_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
    Dim cn As New Npgsql.NpgsqlConnection("Server=s1;User
Id=u1;Password=p1;Database=d1")
    cn.Open()

    Dim cmd As Npgsql.NpgsqlCommand = cn.CreateCommand
    cmd.CommandText = "drop table if exists t1"
    cmd.ExecuteNonQuery()
    cmd.CommandText = "create table t1(id int, value
varchar(10), primary key(id))"
    cmd.ExecuteNonQuery()
    cmd.CommandText = "delete from t1"
    cmd.ExecuteNonQuery()

    Dim da As New Npgsql.NpgsqlDataAdapter("select * from
t1", cn)
    Dim cb As New Npgsql.NpgsqlCommandBuilder(da)
    Dim ds As New DataSet
    da.Fill(ds)

    '## Insert a new row with id = 1
    ds.Tables(0).Rows.Add(New Object() {1, "value1"})
    da.Update(ds)

    '## change id from 1 to 2
    cmd.CommandText = "update t1 set id = 2 where id
= 1"
    cmd.ExecuteNonQuery()

    '## change value to newvalue
    ds.Tables(0).Rows(0).Item("value") =
"newvalue"
    '## update should fail, and make a DBConcurrencyException
    Dim count As Integer = da.Update(ds)
    '## count is 1, even if the isn't updated in the database
    Debug.WriteLine("Count: " & count.ToString)

    cn.Close()
  End Sub

Hope that this could help you.
Date: 2008-05-14 02:37
Sender: Josh Cooley

I ran some tests in the latest CVS and couldn't reproduce this
problem.  Could you please a build from CVS or if you wait a
bit, we'll have beta 4 available.
Date: 2008-04-28 09:28
Sender: Christian Holzner

I tried it with all four overloads
(DbDataAdapter.Update(DataSet),
DbDataAdapter.Update(DataRow[]),
DbDataAdapter.Update(DataTable),
DbDataAdapter.Update(DataSet, String)), and the result is
always the same.

When I set preloadreader=false then all works fine.
Date: 2008-04-24 16:19
Sender: Josh Cooley

Which overload of Update are you using?  There doesn't seem to
be an overload that takes a single DataRow.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item