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. With out SQL identity column inserting the datas, via asp.net

With out SQL identity column inserting the datas, via asp.net

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netdatabasetutorial
4 Posts 4 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.
  • M Offline
    M Offline
    Member 3879881
    wrote on last edited by
    #1

    Hi in sql, "identity column" will automatically increase the value of its own, wenever other columns getting the value. But in my case i have mentioned my column datatype as varchar, so "identity" wont work out here. i want to insert my datas like this format for my ID Column, ID V00000001 V00000002 V00000003 . . . V00000023 how to achieve using asp.net Thanks & Regards, Member 3879881, please don't forget to vote on the post

    N M T 3 Replies Last reply
    0
    • M Member 3879881

      Hi in sql, "identity column" will automatically increase the value of its own, wenever other columns getting the value. But in my case i have mentioned my column datatype as varchar, so "identity" wont work out here. i want to insert my datas like this format for my ID Column, ID V00000001 V00000002 V00000003 . . . V00000023 how to achieve using asp.net Thanks & Regards, Member 3879881, please don't forget to vote on the post

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      If the data always begins with "V" I would use the idendity column and concatenate either in a calculated column or in my data/business layer to form the field. Otherwise, add an insert trigger to the table and use string functions to convert to a number, find the next in the sequence, then insert the column.


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • M Member 3879881

        Hi in sql, "identity column" will automatically increase the value of its own, wenever other columns getting the value. But in my case i have mentioned my column datatype as varchar, so "identity" wont work out here. i want to insert my datas like this format for my ID Column, ID V00000001 V00000002 V00000003 . . . V00000023 how to achieve using asp.net Thanks & Regards, Member 3879881, please don't forget to vote on the post

        M Offline
        M Offline
        Morgs Morgan
        wrote on last edited by
        #3

        Before inserting, get the max Id number from your database, increment it by 1 (or your wish) and then insert a new record in the table using an incremented Id. You gona have to do some logic for the correct number of zeros to be put before the actuall number.

        1 Reply Last reply
        0
        • M Member 3879881

          Hi in sql, "identity column" will automatically increase the value of its own, wenever other columns getting the value. But in my case i have mentioned my column datatype as varchar, so "identity" wont work out here. i want to insert my datas like this format for my ID Column, ID V00000001 V00000002 V00000003 . . . V00000023 how to achieve using asp.net Thanks & Regards, Member 3879881, please don't forget to vote on the post

          T Offline
          T Offline
          Tech Code Freak
          wrote on last edited by
          #4

          For that, you have to do the following..... 1) First retrieve the max id from your database. 2) Then convert the number part of data i.e. 00000001 to int. 3) Then increment it. 4) According to the number, concatenate that number of 0's and V to the incremented number. 5) Insert this id to your database. 6) Enjoy! :thumbsup:

          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