Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 insert and get ID, but with 'ADODB.Command' from MM

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-08-08 : 17:25:08
jerry writes "I started with the sql server 2000 code you displayed for insert, then get ID, however, the .Command is a little different.

Do you have a solution for the following code, so, after the insert, I can pass the id to the next page?


MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")" + " select @@identity";

if (!MM_abortEdit) {
// execute the insert
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute().nextrecordset;

//Retrieve the @@IDENTITY value
newID = MM_editCmd(0);

Response.Redirect(MM_editRedirectUrl + "?id=" + newID);



here is the line where it chokes:
newID = MM_editCmd(0);

heres the official error:

ADODB.Command error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.


thanks,
jerry"
   

- Advertisement -