|
 |
asptoday_discuss thread: recordset
Message #1 by kcwong19@h... on Wed, 20 Feb 2002 10:01:08
|
|
do while not rsRelated.EOF
set rsUpdateNo = server.CreateObject ("ADODB.Recordset")
rsUpdateNo.ActiveConnection = conn
rsUpdateNo.CursorType = 2
rsUpdateNo.LockType = 3
rsUpdateNo.CursorLocation = 3
sql = " Update SoalanDiagnosis set StatusSoalan = 'N' where NoSoalan = '"&
rsRelated("NoSoalan") &"' "
rsUpdateNo.Source = sql
rsUpdateNo.Open
rsRelated.MoveNext
'rsUpdateNo.Close
set rsUpdateNo = nothing
loop
why i can't close the rsUpdateNo? when i close the rsUpdateNo, 'operation
not allowed when object is closed' will occur. what should i do?
Message #2 by HKY <hkyeong1@y...> on Wed, 20 Feb 2002 02:23:28 -0800 (PST)
|
|
hi kcwong:
try this:
do while not rsRelated.EOF
set rsUpdateNo = server.CreateObject
("ADODB.Recordset")
rsUpdateNo.ActiveConnection = conn
rsUpdateNo.CursorType = 2
rsUpdateNo.LockType = 3
rsUpdateNo.CursorLocation = 3
sql = " Update SoalanDiagnosis set StatusSoalan
'N' where NoSoalan = '"&
rsRelated("NoSoalan") &"' "
rsUpdateNo.Source = sql
rsUpdateNo.Open
rsRelated.MoveNext
rsUpdateNo.Close
'set rsUpdateNo = nothing
loop
set rsUpdateNo = nothing
-->u cannot set rsupdateno = nothing
inside a loop
--- kcwong19@h... wrote:
> do while not rsRelated.EOF
> set rsUpdateNo = server.CreateObject
> ("ADODB.Recordset")
> rsUpdateNo.ActiveConnection = conn
> rsUpdateNo.CursorType = 2
> rsUpdateNo.LockType = 3
> rsUpdateNo.CursorLocation = 3
> sql = " Update SoalanDiagnosis set StatusSoalan
> 'N' where NoSoalan = '"&
> rsRelated("NoSoalan") &"' "
> rsUpdateNo.Source = sql
> rsUpdateNo.Open
> rsRelated.MoveNext
> 'rsUpdateNo.Close
> set rsUpdateNo = nothing
> loop
> why i can't close the rsUpdateNo? when i close the
> rsUpdateNo, 'operation
> not allowed when object is closed' will occur. what
> should i do?
>
>
=====
Regards,
HKY
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com
Message #3 by "asame" <asame00@y...> on Wed, 20 Feb 2002 10:43:03 -0000
|
|
Close your rsUpdateNo outside the loop. You cannot loop a closed object.
----- Original Message -----
From: <kcwong19@h...>
To: "ASPToday Discuss" <asptoday_discuss@p...>
Sent: Wednesday, February 20, 2002 10:01 AM
Subject: [asptoday_discuss] recordset
> do while not rsRelated.EOF
> set rsUpdateNo = server.CreateObject ("ADODB.Recordset")
> rsUpdateNo.ActiveConnection = conn
> rsUpdateNo.CursorType = 2
> rsUpdateNo.LockType = 3
> rsUpdateNo.CursorLocation = 3
> sql = " Update SoalanDiagnosis set StatusSoalan = 'N' where NoSoalan = '"&
> rsRelated("NoSoalan") &"' "
> rsUpdateNo.Source = sql
> rsUpdateNo.Open
> rsRelated.MoveNext
> 'rsUpdateNo.Close
> set rsUpdateNo = nothing
> loop
> why i can't close the rsUpdateNo? when i close the rsUpdateNo, 'operation
> not allowed when object is closed' will occur. what should i do?
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Message #4 by agaisin@c... on Wed, 20 Feb 2002 10:00:24 +0000
|
|
side notes:
First, all this may be more appropriate to do in a stored procedure.
Second, if you choose to do it this way, why bother creating and destroying the recordset object inside the loop - not only could
the recordset object be reused, but even better is instead of creating a recordset in each loop you can just use the conn.execute()
method like this:
do while not rsRelated.EOF
...
conn.execute sql,lngRecordsAffected, adCmdText or adExecuteNoRecords
...
loop
That way you don't have to bother with a recordset at all!
hth,
Arthur Gaisin
---- Message from "asame" <asame00@y...> at Wed, 20 Feb 2002 10:43:03 -0000 ------
Close your rsUpdateNo outside the loop. You cannot loop a closed object.
----- Original Message -----
From: <kcwong19@h...>
To: "ASPToday Discuss" <asptoday_discuss@p...>
Sent: Wednesday, February 20, 2002 10:01 AM
Subject: [asptoday_discuss] recordset
> do while not rsRelated.EOF
> set rsUpdateNo = server.CreateObject ("ADODB.Recordset")
> rsUpdateNo.ActiveConnection = conn
> rsUpdateNo.CursorType = 2
> rsUpdateNo.LockType = 3
> rsUpdateNo.CursorLocation = 3
> sql = " Update SoalanDiagnosis set StatusSoalan = 'N' where NoSoalan = '"&
> rsRelated("NoSoalan") &"' "
> rsUpdateNo.Source = sql
> rsUpdateNo.Open
> rsRelated.MoveNext
> 'rsUpdateNo.Close
> set rsUpdateNo = nothing
> loop
> why i can't close the rsUpdateNo? when i close the rsUpdateNo, 'operation
> not allowed when object is closed' will occur. what should i do?
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
Message #5 by "asame" <asame00@y...> on Wed, 20 Feb 2002 21:13:00 -0000
|
|
You are right, there are cheaper ways of going about it. Other way's would
be to use the getRows (array) or getString methods or scripting dictionary
(server intensive). However, I suspect from the nature of the problem, that
Kwong is new to ASP.
Keep the oil burning Agaisin :)
----- Original Message -----
From: <agaisin@c...>
To: "ASPToday Discuss" <asptoday_discuss@p...>
Sent: Wednesday, February 20, 2002 10:00 AM
Subject: [asptoday_discuss] Re: recordset
> side notes:
> First, all this may be more appropriate to do in a stored procedure.
> Second, if you choose to do it this way, why bother creating and
destroying the recordset object inside the loop - not only could the
recordset object be reused, but even better is instead of creating a
recordset in each loop you can just use the conn.execute() method like this:
> do while not rsRelated.EOF
> ...
> conn.execute sql,lngRecordsAffected, adCmdText or adExecuteNoRecords
> ...
> loop
>
> That way you don't have to bother with a recordset at all!
> hth,
> Arthur Gaisin
>
> ---- Message from "asame" <asame00@y...> at Wed, 20 Feb 2002
10:43:03 -0000 ------
> Close your rsUpdateNo outside the loop. You cannot loop a closed object.
>
> ----- Original Message -----
> From: <kcwong19@h...>
> To: "ASPToday Discuss" <asptoday_discuss@p...>
> Sent: Wednesday, February 20, 2002 10:01 AM
> Subject: [asptoday_discuss] recordset
>
>
> > do while not rsRelated.EOF
> > set rsUpdateNo = server.CreateObject ("ADODB.Recordset")
> > rsUpdateNo.ActiveConnection = conn
> > rsUpdateNo.CursorType = 2
> > rsUpdateNo.LockType = 3
> > rsUpdateNo.CursorLocation = 3
> > sql = " Update SoalanDiagnosis set StatusSoalan = 'N' where NoSoalan
'"&
> > rsRelated("NoSoalan") &"' "
> > rsUpdateNo.Source = sql
> > rsUpdateNo.Open
> > rsRelated.MoveNext
> > 'rsUpdateNo.Close
> > set rsUpdateNo = nothing
> > loop
> > why i can't close the rsUpdateNo? when i close the rsUpdateNo,
'operation
> > not allowed when object is closed' will occur. what should i do?
> >
>
>
>
> _________________________________________________________
>
> Do You Yahoo!?
>
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
|
|
 |