|
-
Apr 30th, 2009, 05:35 AM
#1
Thread Starter
Addicted Member
[RESOLVED] why I can update the recordset?
Dear all,
Following is my code. I want to know why I can still update the recordset and the result is reflected in the database even I am using adOpenForwardOnly? Thanks
Code:
aStrsql = " select ...from ... where ..."
If fn_SqlOpenRS(aRs, aStrsql, adCmdText, gConnect_Main, adUseServer, adOpenForwardOnly) Then
i = 0
While Not aRs.EOF
' do some calculation..
aRs!s_totalAmount = aRs!r_totalAmount
..
aRs!s_last_update_time = Now
aRs!s_remark = "SW_frmMassUpdate -> f_confirm_Redem -> From Corresponding Redemption"
aRs.Update
i = i + 1
aRs.MoveNext
Wend
Call fn_closeADOrs(aRs)
Else
MsgBox ("Error in opening the query."), vbCritical, gProjectName_SW
End If
I can still live in my current job because I am here 
-
Apr 30th, 2009, 06:52 AM
#2
Re: why I can update the recordset?
Forward Only has nothing to do with whether or not a recordset is updatable. All it means is that you can only work your way forward through it. So this:-
whould not work. This performs better than a two way recordset but has the obvious limitations that you can't go backwards.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Apr 30th, 2009, 07:52 AM
#3
Re: why I can update the recordset?
Last edited by Pradeep1210; Apr 30th, 2009 at 07:59 AM.
-
Apr 30th, 2009, 08:05 AM
#4
Re: why I can update the recordset?
 Originally Posted by Pradeep1210
Try using adLockReadOnly
Why would you do that? He's trying to update the recordset.
-Max
The name's "Peck" .... "Max Peck"
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." - Red Adair
-
Apr 30th, 2009, 10:46 AM
#5
Thread Starter
Addicted Member
Re: why I can update the recordset?
thanks all.
My question is: Can adOpenForwardOnly perform aRs.update?
I can still live in my current job because I am here 
-
Apr 30th, 2009, 10:50 AM
#6
Re: why I can update the recordset?
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Apr 30th, 2009, 11:10 AM
#7
Thread Starter
Addicted Member
Re: why I can update the recordset?
I can still live in my current job because I am here 
-
Apr 30th, 2009, 01:20 PM
#8
Re: why I can update the recordset?
Is this concept totally wrong
I afraid so .
I think you've completely missunderstood the purspose of adOpenForwardOnly . It's nothing to do with whether or not the recordset is read only. The only affect it has is that it means you can't work backwards through the rescordset. Because it doesn't need to support working backwards it's 'lighter'. By that I mean that it uses less memory and will perform quicker. Most of the time, when you open a recordet, you'll want to start at the beginning and work forward until you reach the end. If that's what you're doing then it makes sense to use adOpenForwardOnly because it'll be a bit quicker and you're not losing anything because you don't want to work backwards anyway.
There are quite a few different qualifiers you can choose between when opening a recordset and they behave in different ways in combination. This site gives quite a nice simplistic view. For a more complete analysis you could check MSDN.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Apr 30th, 2009, 02:36 PM
#9
Re: why I can update the recordset?
Think of adOpenForwardOnly as a one-way street.... but I can still go into shops on the street and purchase items....but, I cannot go back to previous shops - it's a one-way street.
adOpenKeyset is a two-way street... allowing me to go forward and backwards up and down the street & visiting any shop along the way.
It's possible to have adOpenForwardOnly & adLockReadOnly .... all the shops on the one-way street are closed ... all I can do is look in through the windows.
It's also possible to adOpenKeyset & adLockReadOnly ... all the shops on the two way street are closed... all I can do is look in through the windows.
Does that help?
=tg
-
Apr 30th, 2009, 04:04 PM
#10
Re: why I can update the recordset?
It's probably worth taking a look at the FAQ article What do the parameters of the recordset.Open method mean?, as it gives explanations of adOpenForwardOnly/adLockReadOnly/etc.
-
Apr 30th, 2009, 11:58 PM
#11
Re: why I can update the recordset?
adOpenForwardOnly is a CursorType, not a LockType, so it won't prevent one from an updating a recordset.
-
May 1st, 2009, 02:36 AM
#12
Thread Starter
Addicted Member
Re: why I can update the recordset?
 Originally Posted by techgnome
Think of adOpenForwardOnly as a one-way street.... but I can still go into shops on the street and purchase items....but, I cannot go back to previous shops - it's a one-way street.
adOpenKeyset is a two-way street... allowing me to go forward and backwards up and down the street & visiting any shop along the way.
It's possible to have adOpenForwardOnly & adLockReadOnly .... all the shops on the one-way street are closed ... all I can do is look in through the windows.
It's also possible to adOpenKeyset & adLockReadOnly ... all the shops on the two way street are closed... all I can do is look in through the windows.
Does that help?
=tg
a good example. Get it. thanks
I can still live in my current job because I am here 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|