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. Web Development
  3. ASP.NET
  4. how to add

how to add

Scheduled Pinned Locked Moved ASP.NET
databasehelpcsharpasp-nettutorial
3 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.
  • P Offline
    P Offline
    Pratheepa
    wrote on last edited by
    #1

    Dear All, I used Ms access as a database and the table contains 3 columns as Id, Name and email. I set the Id as a autonumber as well as the primary key. my problem is, how to add code in asp.net form to make the Id get added automatically in database. My program works well if i give unique value to id but i don't want to show id on the form. cud anyone help me? also i tried in another way --- designed a query in database and sorted the id column in descending order. In asp.net i took the query's first record's id and add by one. set it as a new value. it works but the problem is, for ex: if the last record's id is 4 and when i add by one 1, I get the new id as 41 instead of 5. cud u help me to sort out this problem?

    S C 2 Replies Last reply
    0
    • P Pratheepa

      Dear All, I used Ms access as a database and the table contains 3 columns as Id, Name and email. I set the Id as a autonumber as well as the primary key. my problem is, how to add code in asp.net form to make the Id get added automatically in database. My program works well if i give unique value to id but i don't want to show id on the form. cud anyone help me? also i tried in another way --- designed a query in database and sorted the id column in descending order. In asp.net i took the query's first record's id and add by one. set it as a new value. it works but the problem is, for ex: if the last record's id is 4 and when i add by one 1, I get the new id as 41 instead of 5. cud u help me to sort out this problem?

      S Offline
      S Offline
      sarang_k
      wrote on last edited by
      #2

      First of all you have to find the max id from the table,if it is blank then store in a variable 1 and insert into table and if it is not blank then add to the result +1 and then insert into table.

      1 Reply Last reply
      0
      • P Pratheepa

        Dear All, I used Ms access as a database and the table contains 3 columns as Id, Name and email. I set the Id as a autonumber as well as the primary key. my problem is, how to add code in asp.net form to make the Id get added automatically in database. My program works well if i give unique value to id but i don't want to show id on the form. cud anyone help me? also i tried in another way --- designed a query in database and sorted the id column in descending order. In asp.net i took the query's first record's id and add by one. set it as a new value. it works but the problem is, for ex: if the last record's id is 4 and when i add by one 1, I get the new id as 41 instead of 5. cud u help me to sort out this problem?

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Pratheepa wrote:

        cud u help me to sort out this problem?

        Your basic issue, apart from not being able to spell, is that you appear to be adding to the number as a string. If you convert it to a number, you can add 1 to it. Not sure if that is the best option. Most people have databases with ids, which they store with their data, but don't show to the user.

        Christian Graus Driven to the arms of OSX by Vista. Please read this[^] if you don't like the answer I gave to your question. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.

        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