Truncate Multiple fields in Dataset

WellyJones

New member
Joined
Jan 3, 2008
Messages
2
Programming Experience
Beginner
Hi,

Sorry if this post has been repeated.

I have a dataset from an SQL database, i want to take multiple records from the first column and remove the first 3 characters.

Can anyone explain what the best way is of doing this?

Thank you

Wellyjones
 
Then you'd have to loop through the DataTable and use the String.Substring method to remove the first three characters of the value in a particular column in each row, e.g.
VB.NET:
For Each row As DataRow In table.Rows
    row("Column") = CStr(row("Column")).Substring(2)
Next row
This code would fail if any value was shorter than four characters, so you'd have to add some checking for that condition to make it robust.
 
Can anyone explain what the best way is of doing this?

actually, selecting it twice is the easiest way:

SELECT name, SUBSTR(name, 4) as trunc_name FROM person


If you need the full name, use the name result. If you need the trunced name, use that instead


SQL is Oracle syntax
 
Back
Top