|
 |
access_asp thread: select query followed by update
Message #1 by "Pieter" <pieter.schockaert@c...> on Tue, 25 Sep 2001 13:53:43
|
|
Hi,
In an ASP script, I first do a SELECT:
var Rs = Server.CreateObject("ADODB.Recordset");
var myQuery = 'SELECT password FROM Person WHERE id="'+userid.text+'";';
Rs.Open(myQuery, Conn);
this works, then I do something which isn't relevant for this question
followed by an UPDATE:
var myUpdate = 'UPDATE Person SET email="'+email.text+'" WHERE
id="'+userid.text+'";';
Rs.Open(myUpdate, Conn);
But when executing this last line, I get this error:
ADODB.Recordset error '800a0e79'
The operation requested by the application is not allowed if the object is
open.
When I close Rs, the error is the same except "... not allowed if the
object is closed.". What am I doing wrong?
Furthermore: is the field name maybe a reserved word of OLEDB?
please help!
Pieter
Message #2 by "Zimmer Computer Consulting" <zee@t...> on Wed, 26 Sep 2001 12:35:49 -0700
|
|
The "SELECT" SQL keyword here creates a recordset.
The "UPDATE" SQL keyword doesn't create a recordset, but changes the data in
the table without retrieving it. One possibility would be to create an ADO
command object and then execute your UPDATE string.
Here is a sample in vbScript:
' Establish connection
DatabaseConnection = "<Your Connection String here>"
' Instantiate a command object
Set UpdateCommand = CreateObject( "ADODB.Command" )
UpdateCommand.ActiveConnection = DatabaseConnection
UpdateCommand.CommandType = adCmdText
''' SET THE COMMAND TEXT
UpdateCommand.CommandText = "UPDATE Person SET email='" _
& email.text & "'WHERE id='" & userid.text & "'";
' Release the object
set UpdateCommand = nothing
----- Original Message -----
From: Pieter <pieter.schockaert@c...>
To: Access ASP <access_asp@p...>
Sent: Tuesday, September 25, 2001 1:53 PM
Subject: [access_asp] select query followed by update
> Hi,
>
> In an ASP script, I first do a SELECT:
>
> var Rs = Server.CreateObject("ADODB.Recordset");
> var myQuery = 'SELECT password FROM Person WHERE id="'+userid.text+'";';
> Rs.Open(myQuery, Conn);
>
> this works, then I do something which isn't relevant for this question
> followed by an UPDATE:
>
> var myUpdate = 'UPDATE Person SET email="'+email.text+'" WHERE
> id="'+userid.text+'";';
> Rs.Open(myUpdate, Conn);
>
> But when executing this last line, I get this error:
> ADODB.Recordset error '800a0e79'
> The operation requested by the application is not allowed if the object is
> open.
>
> When I close Rs, the error is the same except "... not allowed if the
> object is closed.". What am I doing wrong?
> Furthermore: is the field name maybe a reserved word of OLEDB?
>
> please help!
> Pieter
Message #3 by "Pieter" <pieter.schockaert@c...> on Thu, 27 Sep 2001 11:21:14
|
|
Thanks for your reply!
In the meantime I found another solution: I made an ODBC connection and
then used the execute command on the recordset with the Update command.
Pieter
|
|
 |