recordset.update updates > 1 row 
Author Message
 recordset.update updates > 1 row

I am using VB6 SP3 on Win2000 with ADO2.1 referenced in my project.

I am opening a recordset with the following SQL:
SELECT oh_lock FROM Order_Header WHERE oh_id = '1'
(oh_id is the key field and this SQL returns 1 row)
I then write to the database on the following condition:
If (rst!oh_lock & "") = "" Then
    rst!oh_lock = "hello"
    rst.Update
Else ...

The trouble is, this sets oh_lock in ALL records in Order_Header
where oh_lock is null to "hello".

I can fix this by changing the SQL to:
SELECT oh_id, oh_lock FROM Order_Header WHERE oh_id = '1'
Now, only 1 row (ie where oh_id = '1') will be updated.

Is this a bug or is this supposed to happen? It doesn't seem right to me.

Mark

ps I am using Access database, adLockOptimistic and adOpenForwardOnly



Fri, 27 Sep 2002 03:00:00 GMT  
 recordset.update updates > 1 row
I don't understand your question.  You queried for and found one record and
then you updated that one record?


Quote:
> I am using VB6 SP3 on Win2000 with ADO2.1 referenced in my project.

> I am opening a recordset with the following SQL:
> SELECT oh_lock FROM Order_Header WHERE oh_id = '1'
> (oh_id is the key field and this SQL returns 1 row)
> I then write to the database on the following condition:
> If (rst!oh_lock & "") = "" Then
>     rst!oh_lock = "hello"
>     rst.Update
> Else ...

> The trouble is, this sets oh_lock in ALL records in Order_Header
> where oh_lock is null to "hello".

> I can fix this by changing the SQL to:
> SELECT oh_id, oh_lock FROM Order_Header WHERE oh_id = '1'
> Now, only 1 row (ie where oh_id = '1') will be updated.

> Is this a bug or is this supposed to happen? It doesn't seem right to me.

> Mark

> ps I am using Access database, adLockOptimistic and adOpenForwardOnly



Thu, 03 Oct 2002 03:00:00 GMT  
 recordset.update updates > 1 row



Quote:
> I don't understand your question.  You queried for and found one record
and
> then you updated that one record?

**More than one** record gets updated with "hello" in the oh_lock field.
Another fix I found was to use adOpenDynamic instead of
adOpenForwardOnly.

Mark

Quote:



> > I am using VB6 SP3 on Win2000 with ADO2.1 referenced in my project.

> > I am opening a recordset with the following SQL:
> > SELECT oh_lock FROM Order_Header WHERE oh_id = '1'
> > (oh_id is the key field and this SQL returns 1 row)
> > I then write to the database on the following condition:
> > If (rst!oh_lock & "") = "" Then
> >     rst!oh_lock = "hello"
> >     rst.Update
> > Else ...

> > The trouble is, this sets oh_lock in ALL records in Order_Header
> > where oh_lock is null to "hello".

> > I can fix this by changing the SQL to:
> > SELECT oh_id, oh_lock FROM Order_Header WHERE oh_id = '1'
> > Now, only 1 row (ie where oh_id = '1') will be updated.

> > Is this a bug or is this supposed to happen? It doesn't seem right to
me.

> > Mark

> > ps I am using Access database, adLockOptimistic and adOpenForwardOnly



Fri, 04 Oct 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. When updating recordset I get error -2147467259 (to many rows affected by update)

2. 2nd SQL Server update after update text field corrupts row - using RDO

3. Insufficent key column information for updating and refreshing:Too many rows to update

4. ADODB.Recordset.Update does not update?

5. Bound controls not updating ADO with adodc.recordset.update command

6. Updating textbox via code not updating recordset

7. Recordset.Update doesn't update on runtime only when debugging the code

8. Update a recordset with station1, I can't see the update with station2

9. Update recordset with Update Batch

10. rdo-->ODBC-->SQL6.0 (Errors on Addnew, Update)

11. Update recordset from another recordset

12. open recordset, change connection, update recordset?

 

 
Powered by phpBB® Forum Software