insert multiple records into access database-how?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • r_o
    New Member
    • Jul 2006
    • 35

    insert multiple records into access database-how?

    hi, im somehow new to web development,
    im developing an application with ms access 2003 using asp
    i want to know if there's a way to make a bulk insert into the database
    using the recordset object.
    im trying to use the updatebatch method by im still not able to perform(i dont know if it's the right 1 to use)

    in my database i use an autonumber field type as my PK
    if there's a chance that 2 users would be inserting data as the same time
    would that make a problem in the database, and if so how can i deal with it.

    So if somebody could provide me with a little code example , it would be awsome

    Thank You
  • lakshmanmcaj
    New Member
    • Jul 2006
    • 35

    #2
    hi

    u can use this code of auto number creations ok
    ers.open "select max(val(id)) from empid",db,0,1

    if isNull(ers(0))= true then
    else
    wid=ers(0)+1
    response.Write( wid)
    end if

    and i dont know correctly ur problem of "insert multiple records into access database" please explain clearly

    Comment

    • r_o
      New Member
      • Jul 2006
      • 35

      #3
      hi,
      im talking about inserting them at once like a batch or bulk
      regarding the autonumber, i've set it to auto increment so it increments alone
      but i dont know if that could be dangerous on the web.
      another question please:
      how after inserting just one record to the database can i get the value of the autonumber inserted ( i want to retrieve it among other fields withou having to make 2 accesses to the database) itries
      "select * from beneficiary where beneficiary_cod e=(select max(beneficiary _code) from beneficiary)" right after the insert operation but iot returned an error!!!
      is there a solution for that
      or maybe there's a beter way?

      Comment

      • tejaswini
        New Member
        • Jul 2006
        • 7

        #4
        hi

        why dont you get the last inserted id using theSQl last@@Identity.

        Comment

        • lakshmanmcaj
          New Member
          • Jul 2006
          • 35

          #5
          Hi

          ers.open "select max(beneficiary _code) from beneficiary",db ,0,1

          if isNull(ers(0))= true then
          else
          wid=ers(0)+1
          response.Write( wid)
          end if

          Now u get a ID u can store that in one column of database like autonumber beneficiary_Id. like that.

          what error msg u got inserting multiple records in Database please..

          Comment

          • r_o
            New Member
            • Jul 2006
            • 35

            #6
            ok i have a question about this @@IDENTITY query

            if 2 users were inserting data at the same time,there would be 2 ADO connection created 1 for each right.

            so this query (select @@IDENTITY as id) does it retrieve the last id inserted by the user issuing the call to the query ie. for the ADO connection specific to that user
            or does it include values inserted by the other one as well?

            if it doesn't my problem is solved but if it does, then i would need to insert multiple records into one table at once with one access to the database,
            if there's a way to do that i wish someone could pass it to me please

            Thank You

            Comment

            Working...