Re: EditMode gets reset to adEditNone when adding multiple records
- From: Sven De Bont <SvenDeBont@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 28 Aug 2006 00:41:02 -0700
Stephen,
The right property is the Status for a record. This is a bit encoded field.
If you have done things correctly, if you iterate over your records, any new
records will have the bottom bit set (adRecNew).
I tried checking the Status property as you suggested and came to the
following conclusion (client code listed below - see previous post for full
code listing):
The recordset contains 2 records to start with.
[/code]
'rstSelectecGroup.RecordCount returns 2
rstSelectedGroups.AddNew
'Status = adRecNew
rstSelectedGroups.Fields("ntuser_usergroup_id").Value =
GetNextSequece("SecurityID")
'Status = adRecNew
rstSelectedGroups.Fields("ntuser_id").Value =
rstUsers.Fields("ntuser_id").Value
'Status = adRecNew
rstSelectedGroups.Fields("usergroup_id").Value =
rstAvailableGroups.Fields("usergroup_id").Value
'Status = adRecNew
rstSelectedGroup.Update
'Status = adRecNew
'rstSelectecGroup.RecordCount returns 3: record has been added
rstSelectedGroup.MoveFirst
Do while not rstSelectedGroup.Eof
Debug.Print rstSelectedGroup.Status '<--- returns adRecUnmodified for
ALL records
rstSelectedGroup.MoveNext
Loop
[/end code]
The actual code is a little different, but right before the iteration, the
current record is still the new one and has status adRecNew. So apparently
when I call MoveFirst, the Status gets reset to adRecUnmodified.
I must admit that I don't have much experience with disconnected ADO
recordsets (plus it's been a while), but I don't think that's how they should
behave.
Any ideas would be welcome.
Regards,
--
Sven De Bont - MCAD
"Stephen Howe" wrote:
.After I took a closer look, I found that the other added records werestill
in the recordset, but had their EditModeproperty reset to adEditNone (so
calling UpdateBatch has no effect on these records).
I think you are drawing the wrong conclusion from the wrong property.
Regardless of the state of EditMode property it has nothing to do with
UpdateBatch.
The EditMode property just indicates whether the current record is being
edited or not.
The right property is the Status for a record. This is a bit encoded field.
See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdcstrecordstatusenum.asp
If you have done things correctly, if you iterate over your records, any new
records will have the bottom bit set (adRecNew).
I can't figure out where exactly the EditMode gets reset.
Probaby when do AddNew (does an implied Update if the current record is
changed) or on an explicit Update or on a
MoveNext/MovePrevious/MoveFirst/MoveNext
Does anyone have any idea what could cause the editmode property getting
reset to adEditNone?
ADO is causing it.
A small failing code example would be useful.
Stephen Howe
- References:
- Re: EditMode gets reset to adEditNone when adding multiple records
- From: Stephen Howe
- Re: EditMode gets reset to adEditNone when adding multiple records
- Prev by Date: Re: ADO error (80004003) on 1 machine
- Next by Date: ADO and VC++ in Visual Studio 2005
- Previous by thread: Re: EditMode gets reset to adEditNone when adding multiple records
- Next by thread: ADO and VC++ in Visual Studio 2005
- Index(es):