SELECT @@IDENTITY IN ADO question

Last post 03-11-2002 9:23 AM by amuchnik@fundbalance.com. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-07-2002 9:34 AM

    SELECT @@IDENTITY IN ADO question

    Do anybody know how to obtain RecordNum from last inserted record. RecordNum is defined in MYTABLE as IDENTITY column.

    To insert new record I issue AddNew and Update methods from Recordset object.

    Then I create SQL statement like this
    SELECT @@IDENTITY AS RecNo FROM MYTABLE
    COMMAND object and issue EXECUTE method for this object, get result Recordset pRsCommand and then retrieve result like this:

    lRecNo = (long)pRsCommand->Fields->Item[_variant_t("RecNo")]->Value.lVal

    Connection object is the same.

    It doesn't crash but however the result obtained is like -13110.

    What is wrong in this scenario.

    I use Pervasive SP4 and Visual C++ 6.0.

    In Pervasive Control Center it works as it should be.

    Thank you for any help
    Aleksandr
  • 03-08-2002 1:43 PM In reply to

    Re: SELECT @@IDENTITY IN ADO question

    Aleksandr,

    Are you using PervasiveOLEDB or ODBC?

    -Darin
  • 03-11-2002 9:18 AM In reply to

    Re: SELECT @@IDENTITY IN ADO question

    quote:

    Aleksandr,

    Are you using PervasiveOLEDB or ODBC?

    -Darin

  • 03-11-2002 9:23 AM In reply to

    Re: SELECT @@IDENTITY IN ADO question

    quote:

    Aleksandr,

    Are you using PervasiveOLEDB or ODBC?

    -Darin




    Darin,

    I created database using Pervasive Control Center and I am using in Connection object DSN for this database.

    This is the piece of code where connection is set up

    hr = pCn->Open(_bstr_t(myDSN),_bstr_t(sUser),_bstr_t(sPWD),NULL);

    where myDSN is DSN for database created,
    sUser and sPWD is empty.

    So I use ODBC connection

    Thank you
    Aleksandr

Page 1 of 1 (4 items)