Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. @@IDENTITY detection with ADO

@@IDENTITY detection with ADO

Scheduled Pinned Locked Moved Database
databasec++helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    darkbyte
    wrote on last edited by
    #1

    Is there a way to detect if a specific DB can support @@IDENTITY ? Problem is, its possible to change my connection string depending on the database i want to connect to, as a client choice. But not all DB systems make use of @@IDENTITY. My tests here are with MSAccess and MSDE and both support it. I'm using ADO from C++ in VC 2003. Thx for any replies, even if negative.

    M 1 Reply Last reply
    0
    • D darkbyte

      Is there a way to detect if a specific DB can support @@IDENTITY ? Problem is, its possible to change my connection string depending on the database i want to connect to, as a client choice. But not all DB systems make use of @@IDENTITY. My tests here are with MSAccess and MSDE and both support it. I'm using ADO from C++ in VC 2003. Thx for any replies, even if negative.

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Although I must admit I don't have first-hand experience with anything but Access or MSDE, you could simply create a test function where you execute an insert and catch any exceptions your SELECT @@IDENTITY throws. If there's no exception thrown (and you receive a meaningful result) then @@IDENTITY should work later on as well... Or: Do not rely on a DB supplying such an information in a certain way but create a stored procedure to perform your inserts and let the procedure return the ID of the newly created element. That way you might be more flexible than hard-coding it in your program. Regards, mav

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups