Spliting a String
-
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.
-
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.
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 .
-
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 .
Thank you very much
-
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.
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...
-
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.
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..