Results 1 to 2 of 2

Thread: @@IDENTITY help

  1. #1
    Join Date
    Oct 2003

    Unanswered: @@IDENTITY help

    I am having trouble with @@IDENTITY. I am trying to get the id of the row I just inserted into a table. I am creating the program in JDK1.4 and connecting to a MS Access 2000 database.

    Am I setting up my SQL statement correctly.

        sql = "INSERT INTO miscellaneous_info(manager_comp, manager_discount, employee_discount, package_plan) " +
              "VALUES(" + Double.valueOf(jTextFieldManagerComp.getText()).doubleValue() + ", " +
                          Double.valueOf(jTextFieldManagerDiscount.getText()).doubleValue() + ", " +
                          Double.valueOf(jTextFieldEmployeeDiscount.getText()).doubleValue() + ", " +
                          Double.valueOf(jTextFieldPackagePlan.getText()).doubleValue() + ") " +
              "SELECT @@IDENTITY AS 'id';";
    This is the error I receive when I run the insert statement.
    [Microsoft][ODBC Microsoft Access Driver] Missing semicolon (";") at end of SQL statement. The " around the ; are to keep the smily faces from showing.


    Jason Franz

  2. #2
    Join Date
    Feb 2002
    You can execute the insert first then execute the @@identity. Or combine these into 1 (separated by a semicolon) sql statement but you would have 2 recordsets to handle. I am not sure if the driver you are using will support multiple recordsets - try moving the semicolon to the end of the insert statement (before the select @@identity).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts