Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Fabiano Arruda #1
retrieving last record inserted using @@IDENTITY - ASPJScript
Im triyng to retrieve the last record inserted usnig the "Insert" Server
Behavior, in a table that have an auto-incrementig id column. Im trying this by
requesting the SQL variable @@IDENTITY... but its returning nothing! I modified
the Server Behavior Code like this:
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.CommandText = "SELECT @@IDENTITY as vai";
var teste = MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
and then Im retrievind the variable teste, but I got a error because nothing
is assigned to it at all... whats wrong?
Fabiano Arruda Guest
-
Retrieving ID of Last Inserted Table
Hi, I've done a search of the forums and although I've found similar questions none of them seemed to answer my question. I'm currently writing... -
ID of last record inserted
Is it possible, with a MS Access database, to pull the ID of a record just inserted? I have found various threads and tutorials on various sites... -
Identity from inserted record
I'm inserting a record into a SQL Server database. Once the record has been added, I need the Identity value that SQL Server created. Normally, the... -
mySQL / Last inserted record ID
Hi, I'm using mySQL and wanted to get the ID of the record that I have just inserted in to the table (sentmessages). There is a function in mySQL... -
retrieving identity
It's better to use SCOPE_INDENTITY( ) @@IDENTITY can give a bad answer in some situations. "Kevin Spencer" <kevin@SPAMMERSSUCKtakempis.com> a... -
Lionstone #2
Re: retrieving last record inserted using @@IDENTITY - ASP JScript
..Execute() returns a recordset, not a value. You have to get the value out
of the recordset.
"Fabiano Arruda" <webforumsuser@macromedia.com> wrote in message
news:d4it48$lhg$1@forums.macromedia.com...> Im triyng to retrieve the last record inserted usnig the "Insert" Server
> Behavior, in a table that have an auto-incrementig id column. Im trying
> this by
> requesting the SQL variable @@IDENTITY... but its returning nothing! I
> modified
> the Server Behavior Code like this:
>
> var MM_editCmd = Server.CreateObject('ADODB.Command');
> MM_editCmd.ActiveConnection = MM_editConnection;
> MM_editCmd.CommandText = MM_editQuery;
> MM_editCmd.Execute();
> MM_editCmd.CommandText = "SELECT @@IDENTITY as vai";
> var teste = MM_editCmd.Execute();
> MM_editCmd.ActiveConnection.Close();
>
>
> and then Im retrievind the variable teste, but I got a error because
> nothing
> is assigned to it at all... whats wrong?
>
Lionstone Guest
-
Fabiano Arruda #3
Re: retrieving last record inserted using @@IDENTITY -ASP JScript
and how I supose to do that?
Fabiano Arruda Guest
-
COMALite J of MMCC #4
Re: retrieving last record inserted using @@IDENTITY -ASP JScript
To retrieve a value from a Recordset assigned to a variable, and place it into
a Session variable, use this syntax:
// use "b]Dim rsRecordsetName" followed by "Set" instead of "var" if using
VBscript instead of JScript:
var rsRecordsetName = (any statement that would return an ADODB.Recordset
value);
Session("sessionItem") = rsRecordsetName.Fields.Item("columnName").Value;
On ASP Classic, the second line can be shortened to:
Session("sessionItem") = rsRecordsetName("columnName");
(The shortcut syntax may not work on ASP.NET.)
Don't forget to close the Recordset when you're done with it!
rsRecordsetName.Close();
(if VBscript): Set rsRecordsetName = Nothing
COMALite J of MMCC Guest
-
Les Matthews #5
Re: retrieving last record inserted using @@IDENTITY - ASP JScript
Maybe you would be interested in Tom Muck's extension for ASP:
[url]http://www.tom-muck.com/extensions/help/insertretrieve/?[/url]
"Fabiano Arruda" <webforumsuser@macromedia.com> wrote in message
news:d4j5mi$4g6$1@forums.macromedia.com...> and how I supose to do that?
Les Matthews Guest



Reply With Quote

