tags:

views:

902

answers:

4

I am updating a datawindow with the Update function, which returns 1 to say it is successful, but then the SQLNRows is coming back as 0. When I do this for the first time on my screen, it works, with 1 successful and SQLNRows 1, but when I do a second update on the same screen without closing it inbetween i get 1 successful and SQLNRows 0. Any suggestions why this would be?

+2  A: 

It's been a long time since I've used PB, but isn't the .Update()'s return value simply an indicator of the command (i.e. UPDATE) being successfully performed by the DB? If this is correct then it'll return 1, when successful, even if row values are not actually changing. SqlNRows is the actual indicator of the number of changed rows.

John Paul Jones
+3  A: 

Your question seems to hit a couple of things.

Firstly, as John Paul mentions, Update() will return 1 even if there are no rows updated. There is no specific return value for "nothing to be done."

Secondly, as mentioned in the help file, the value for SQLNRows is DBMS-dependent, so it's hard to comment on the value being filled in there without knowing the DBMS involved. However, regardless of that, since the DataWindow issues a series of INSERTs, UPDATEs and DELETEs that are targeted at only one row, if this value is populated I wouldn't expect it would ever be more than one, no matter how many SQL statements the DataWindow issues. The number of rows affected for the last SQL statement issued should always be one.

If you're trying to find the number of rows affected by a DataWindow Update(), before the Update(), check the value of ModifiedCount() + DeletedCount().

Good luck,

Terry.

Terry
A: 

A good way to tell what's going on if you're using PFC is to use the SQL Spy service. In a non-PFC app, you could put a do-nothing line like beep(1) in the DataWindow's sqlpreview event, set a breakpoint on that line, and use the debugger to watch what's going on. You could also use the SQL statement trace facility or the Database Trace tool as described in Troubleshooting Your Connection in the Connecting to Your Database book.

Hugh Brackett
A: 

I have the same problem of Charmiane, but I'm using a datastore to Update information to the database. so, In this case I'm doing an InsertRow and Update Datawindow event returns O, it means that the information is updated sucesfully. Then, I commit. When I see the information in the database, it's not there, Why? ...I don't know. Please, somebody help me with this. Thaks.

by the other hand: 1. the update propertie of the datawindow object is on. 2. The SQCA.sqcode returns 0 3. The rowCount() event returns 1 (inserted row)

Julianld1782