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. Spliting a String

Spliting a String

Scheduled Pinned Locked Moved ASP.NET
databasehelp
5 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.
  • P Offline
    P Offline
    Paul McGann
    wrote on last edited by
    #1

    I have a unique id in my database that takes the form "EQ0001". I want to split the id after the "EQ" part so i'm left with "EQ" in one part and "0001" in another. The "0001" will then be incremented by one and added back to the "EQ" thus giving "EQ0002". If anyone can help its much appreciated.

    S P V 3 Replies Last reply
    0
    • P Paul McGann

      I have a unique id in my database that takes the form "EQ0001". I want to split the id after the "EQ" part so i'm left with "EQ" in one part and "0001" in another. The "0001" will then be incremented by one and added back to the "EQ" thus giving "EQ0002". If anyone can help its much appreciated.

      S Offline
      S Offline
      Sneha Bisht
      wrote on last edited by
      #2

      Why not you use substring function. string s = EQ0001; string s1 = s.Substring(0, 2) ans - EQ ; string s1 = s.Substring(3, 4) ans - 0001; try this if you want to change string value in coding .

      P 1 Reply Last reply
      0
      • S Sneha Bisht

        Why not you use substring function. string s = EQ0001; string s1 = s.Substring(0, 2) ans - EQ ; string s1 = s.Substring(3, 4) ans - 0001; try this if you want to change string value in coding .

        P Offline
        P Offline
        Paul McGann
        wrote on last edited by
        #3

        Thank you very much

        1 Reply Last reply
        0
        • P Paul McGann

          I have a unique id in my database that takes the form "EQ0001". I want to split the id after the "EQ" part so i'm left with "EQ" in one part and "0001" in another. The "0001" will then be incremented by one and added back to the "EQ" thus giving "EQ0002". If anyone can help its much appreciated.

          P Offline
          P Offline
          Paddy Boyd
          wrote on last edited by
          #4

          You might want to consider creating two fields in your database, one to handle the text part and the other to handle the auto incrementing numeric field. Gives you a bit of flexibility for the point when you suddenly have your 10000th EQ...

          1 Reply Last reply
          0
          • P Paul McGann

            I have a unique id in my database that takes the form "EQ0001". I want to split the id after the "EQ" part so i'm left with "EQ" in one part and "0001" in another. The "0001" will then be incremented by one and added back to the "EQ" thus giving "EQ0002". If anyone can help its much appreciated.

            V Offline
            V Offline
            varma suresh
            wrote on last edited by
            #5

            OledbConnection con=new oleDbconnection("Connection String"); OleDbdataadapter da=new OleDbdataadapter("select MyID from MyTable",con); Dataset ds=new Dataset(); da.fill(ds,"d"); DataTable dt=ds.Tables["d"]; for(int i=0;i<dt.rows.count;i++)> { DataRow dr=dt.Rows[i]; con.open(); Oledbcommand cmd=new OleDbcommand("insert into MyTable (MyId) values ((dr[i].ToString()).SubString(2)) where MyId='"+dr[i].ToString()+"'",con); cmd.ExecuteNonQuery(); con.close(); } over...At One step U can Replace all The Data In Your Table.. Hope This Will Help You..

            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