By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,175 Members | 1,710 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,175 IT Pros & Developers. It's quick & easy.

How do I keep trailing spaces from being trimmed?

P: n/a
I am developing a program that requires me to read a string of data from
a text field in a database. Data is parsed from the string based upon a
starting position/length. If a piece of data doesn't meet the required
field length, then spaces are added, thus my issue. It appears VB.net
is trimming any trailing spaces. What should be a 250 character data
string is only 243 (less 7 trailing spaces). Is there a way to get this
to stop? I manually checked the data in the database counting the number
of characters and 250 was the correct.

-Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Is your data type in your database set to
VARCHAR or is it set to CHAR

VarChar will automaticlly trim spaces... char will pad..

-cJ
"rsine" <an*******@devdex.com> wrote in message
news:Of*************@TK2MSFTNGP09.phx.gbl...
I am developing a program that requires me to read a string of data from
a text field in a database. Data is parsed from the string based upon a
starting position/length. If a piece of data doesn't meet the required
field length, then spaces are added, thus my issue. It appears VB.net
is trimming any trailing spaces. What should be a 250 character data
string is only 243 (less 7 trailing spaces). Is there a way to get this
to stop? I manually checked the data in the database counting the number
of characters and 250 was the correct.

-Thanks
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2

P: n/a
CJ,

It is an AS/400 database that I am connecting into via ODBC. I look at
the data in Access and everything is the right length. I am not sure if
there is something going on when I populate my dataset wherein it is
trimming trailing spaces when I do a .Fill or not. The following is the
code I am using:

Dim mOLEDBCommand As OleDb.OleDbCommand = New OleDb.OleDbCommand(sSQL,
mRemoteConnection)

mOLEDBCommand.CommandTimeout = 60

'issue the SELECT command via SQLAdapter
Dim mOLEDBAdapter As OleDb.OleDbDataAdapter = New
OleDb.OleDbDataAdapter mOLEDBAdapter.SelectCommand = mOLEDBCommand

'establish connection to remote database
mRemoteConnection.Open()

mOLEDBAdapter.Fill(dsRemoteDataset, sRemoteEDIPF)

'close the connection
mRemoteConnection.Close()
Dim sData As String
sData =
dsRemoteDataset.Tables(sRemoteEDIPF).Rows(EDIIndex Pos).Item("Data")

When I do a count of sData, the field has been trimmed.

I appreciate your help and welcome any further suggestions since this
has got me stumped.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.