473,796 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I keep trailing spaces from being trimmed?

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
2 3325
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*******@devd ex.com> wrote in message
news:Of******** *****@TK2MSFTNG P09.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
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.OleDbComm and = New OleDb.OleDbComm and(sSQL,
mRemoteConnecti on)

mOLEDBCommand.C ommandTimeout = 60

'issue the SELECT command via SQLAdapter
Dim mOLEDBAdapter As OleDb.OleDbData Adapter = New
OleDb.OleDbData Adapter mOLEDBAdapter.S electCommand = mOLEDBCommand

'establish connection to remote database
mRemoteConnecti on.Open()

mOLEDBAdapter.F ill(dsRemoteDat aset, sRemoteEDIPF)

'close the connection
mRemoteConnecti on.Close()
Dim sData As String
sData =
dsRemoteDataset .Tables(sRemote EDIPF).Rows(EDI IndexPos).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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
22854
by: Jay Chan | last post by:
I am trying to export data from a SQLServer database into a text file using a stored procedure. I want to be able to read it and debug it easily; therefore, I want all the columns to indent nicely. This means I need to append trailing spaces to a text string (such as "Test1 ") or append leading space in front of a text string that contains a number (such as " 12.00"). Now, the stored procedure works fine when I run it in Query Analyzer....
0
1319
by: SD | last post by:
Hi, a client of mine has parts such as JT220F that have trailing spaces so at first look they seem like duplicates in the ITEM table. Technically they are not because one is JT220F and the other is JT220F + ' ' here is the problem, I'm importing it into SQL Server from SQLBase via ODBC driver, but when the DTS is done the parts are brought over without the trailing spaces. Now I effectively have a "duplicate" parts.
7
7423
by: ITM | last post by:
Can anyone tell me how I can prevent Access adding trailing spaces when I insert a value into a Text column? For example, if I execute the following statement: UPDATE Log SET Log.Title = 'Testing' WHERE Log.Identifier=1; ....then the following statement:
5
5435
by: Tammy | last post by:
I am doing some genealogy research and I have discovered that there is a lot of data available on the web in text format. The problem is that the columns in the files are lined up by spaces. I'd like to be able to import these files into Access or Excel so that they can be sorted. What I plan on doing is adding in commas at the end of each field to create a csv file. What I need to know is how can I easily remove the spaces between...
5
3364
by: Stan Shankman | last post by:
How do I add trailing spaces within a right-justified textBox? In order to add a trailing space to the text in a right-justified textBox, I use to just append a space to the end of the text string. But now, textBox seems to have gotten smarter, as it automatically remove trailing spaces. So the question remains: How now do I add trailing spaces to text inside a right-justified textBox?
0
1939
by: Seth | last post by:
First off, my apologies if this is in the wrong newsgroup, but I hope I'm close enough. I'm trying to do some parsing of a CSV file using OleDbConnection, but for some reason, when I populate my DataSet, it is trimming the trailing spaces. Anybody know why? Here is my code: System.Data.OleDb.OleDbConnection connection = null;
0
1361
by: Les Caudle | last post by:
I'd been using +(\+*)?@(+\.)++ as the validator for an email address. If the user enters a leading or trailing space, the email is invalid. 1. How exactly does one trim leading/trailing spaces with a RegularExpressionValidator? 2. Even though no complaints on email being invalid besides this - are there
17
11886
by: tommy | last post by:
Hi all, I' m adding strings to some fields in my table via Access. The strings sometimes have trailing spaces and I really need to have it that way, but Access truncates trailing spaces. How can I force Access not to truncate?! Thanx, /Toommy
5
2966
by: brian.j.parker | last post by:
Hey all, I've noticed an obscure little quirk: it appears that if you use a login with trailing spaces on the name, SYSTEM_USER automatically trims those trailing spaces in SQL Server 2000, but not SQL Server 2005. Anybody know if this change in behavior is documented? If it is intentional? Is there a "quick fix" to revert to the old behavior (to automatically RTRIM the results of SYSTEM_USER in 2005) until code can be changed?
0
9683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10457
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10231
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10176
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10013
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9054
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7550
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4119
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3733
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.