Trim not working any other suggestions?

runswithsizzors

Well-known member
Joined
May 11, 2005
Messages
70
Location
Northern Michigan
Programming Experience
5-10
I have an excel file that I am uploading and adding to a database. The database column for the state allows only 2 characters. Well the excel files that have been coming in lately have had some extra space.

When they do get uploaded they have that nice � character appended to the state which case the app to fail.

So I am brain dead on string manipulation. I need to take the first 2 characters and use just them. I tried trim and that didn't work. Any body have a suggestion for me. Thanks!
 
Try yourstring.Substring(0, 2).

You'll need to ensure that your string is at least 2 charracters though or it'll throw an exception.

CT
 
Also, this � character could be a line feed character. Cavar suggestion would work best.

You can try to replace the line feed character using the following:

yourString = yourString.Replace(Environment.NewLine, String.Empty)

CT
 
Back
Top