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. General Programming
  3. Visual Basic
  4. Fetch Autonumber from Firebird ?

Fetch Autonumber from Firebird ?

Scheduled Pinned Locked Moved Visual Basic
databasequestionannouncement
5 Posts 3 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.
  • K Offline
    K Offline
    ksenthilbabu
    wrote on last edited by
    #1

    i am developing a project with VB6 and Firebird 2.1.3. When i update the table tblPartyMaster and examines the adoRsParty!PartyID which is a primary key,autoincrement, unique identifier returns 0 (Zero) instead of New PartyID Value which i need for further processing.

    With adoRsParty
    .AddNew
    !CompanyName="Sample Company"
    .Update
    msgbox !PartyID
    End With

    I have create a Generator for PartyID and a Before Insert Trigger on table tblpartyMaster as

    CREATE TRIGGER TR_AI_TBLPARTYMASTER_PARTYID FOR TBLPARTYMASTER
    ACTIVE BEFORE INSERT
    POSITION 0
    AS
    BEGIN
    NEW.PARTYID = GEN_ID(GEN_TBLPARTYMASTER_PARTYID, 1);
    END

    Please Suggest me some ideas for fetching the PrimaryKey (PartyID) Value of newly inserted row. Expecting some advice or ideas or guidance With regards K.Senthil Babu

    M 1 Reply Last reply
    0
    • K ksenthilbabu

      i am developing a project with VB6 and Firebird 2.1.3. When i update the table tblPartyMaster and examines the adoRsParty!PartyID which is a primary key,autoincrement, unique identifier returns 0 (Zero) instead of New PartyID Value which i need for further processing.

      With adoRsParty
      .AddNew
      !CompanyName="Sample Company"
      .Update
      msgbox !PartyID
      End With

      I have create a Generator for PartyID and a Before Insert Trigger on table tblpartyMaster as

      CREATE TRIGGER TR_AI_TBLPARTYMASTER_PARTYID FOR TBLPARTYMASTER
      ACTIVE BEFORE INSERT
      POSITION 0
      AS
      BEGIN
      NEW.PARTYID = GEN_ID(GEN_TBLPARTYMASTER_PARTYID, 1);
      END

      Please Suggest me some ideas for fetching the PrimaryKey (PartyID) Value of newly inserted row. Expecting some advice or ideas or guidance With regards K.Senthil Babu

      M Offline
      M Offline
      Md Marufuzzaman
      wrote on last edited by
      #2

      You can use a storedprocedure, I think trigger is not convenient. Just use an Output parama in your code. If you face any problem please let me know.

      Thanks Md. Marufuzzaman


      I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

      H K 2 Replies Last reply
      0
      • M Md Marufuzzaman

        You can use a storedprocedure, I think trigger is not convenient. Just use an Output parama in your code. If you face any problem please let me know.

        Thanks Md. Marufuzzaman


        I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

        H Offline
        H Offline
        Henry Minute
        wrote on last edited by
        #3

        From my Delphi and Interbase days I remember that the methodology the OP is using (before insert trigger and GEN_ID) is the recommended way of doing things. Unfortunately I have never tried to access Interbase/FireBird from VB and therefore am unable to help.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        1 Reply Last reply
        0
        • M Md Marufuzzaman

          You can use a storedprocedure, I think trigger is not convenient. Just use an Output parama in your code. If you face any problem please let me know.

          Thanks Md. Marufuzzaman


          I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

          K Offline
          K Offline
          ksenthilbabu
          wrote on last edited by
          #4

          Thanks Md. Marufuzzaman, I Created a procedure instead of Trigger along with the generator and called the procedure from the front end for autonumber, it works fine. Thanks A Lot.

          M 1 Reply Last reply
          0
          • K ksenthilbabu

            Thanks Md. Marufuzzaman, I Created a procedure instead of Trigger along with the generator and called the procedure from the front end for autonumber, it works fine. Thanks A Lot.

            M Offline
            M Offline
            Md Marufuzzaman
            wrote on last edited by
            #5

            You are most welcome.. :)

            Thanks Md. Marufuzzaman


            I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.

            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