PC Review


Reply
Thread Tools Rate Thread

How do I keep trailing spaces from being trimmed?

 
 
rsine
Guest
Posts: n/a
 
      9th Oct 2003
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!
 
Reply With Quote
 
 
 
 
CJ Taylor
Guest
Posts: n/a
 
      9th Oct 2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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!



 
Reply With Quote
 
rsine
Guest
Posts: n/a
 
      10th Oct 2003
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(EDIIndexPos).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!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
trailing spaces =?Utf-8?B?cGV0ZXI=?= Microsoft Excel Worksheet Functions 3 18th Oct 2007 11:32 PM
When parsing CSV using OleDbConnection, trailing spaces are trimmed Seth Microsoft ADO .NET 3 18th Jan 2005 03:10 PM
When parsing CSV using OleDbConnection, trailing spaces are trimmed Seth Microsoft C# .NET 0 14th Jan 2005 04:35 PM
Bulk Insert and spaces trimmed at the end of string Sebastien Lange Microsoft ADO .NET 5 2nd Oct 2003 03:34 AM
Re: preserving trailing spaces Dave Peterson Microsoft Excel Misc 0 30th Jul 2003 05:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:23 AM.