Question dataset appending spaces

computer guy

Member
Joined
Feb 12, 2008
Messages
18
Programming Experience
Beginner
I have a dataset and am using the following code to insert new rows.
VB.NET:
Dim row2 As DataRow = Form1.id3Table.NewRow()
            row2.Item(0) = id.title
            row2.Item(1) = id.album
            row2.Item(2) = id.artist
            Form1.id3Table.Rows.Add(row2)
I know that title is "Enter Sandman" but when put into the dataset I get
VB.NET:
"Enter Sandman                 "
.

Every other string I put into the dataset gets filled with " " to make 30 chars.

Does anyone know why it is doing this?


Thank you :)
 
You defined the database column type as CHAR30, not VARCHAR30 or whatever the equivalent is in your database for a fixed-widh vs varying-width column

It is not the dataset adding the spaces, it's the db, because that's how you set it up
 
What database are you all refering to?

The data comes from a text box and is stored in an untyped dataset. I then have the results displayed in a linked DataGridView.

The DataGridView displays.
VB.NET:
"Enter Sandman                 "

If I extract the data from the dataset and put it in a text box. The output is the same as above.

What is causing this?

Thank you :)
 
What database are you all refering to?
Oracle, SQLServer...


What is causing this?
You need to post more code. There is no functionality I know of in a datatable that will pad data in the manner you describe.. Everything I can think of would be a custom format executed when data is read, either when you read it from source before putting it in or read it from datatable before displaying it

Post an example code that demonstrates the issue. Please don't dump 50Kb of your form code into a post and expect us to pick through it; reduce it to only the relevant section
 
ps, if "id" is a reference to some kind of library that is reading the ID3 tag from an MP3, you should know that ID3v1 tags had 30 characters for the title, artist, comment and album fields and if the text within is not terminated with an ASCII nul character then the default parse mode is to read all 30 characters. If the tag was hence written with spaces for padding and no nul character (i.e. written by a broken tagging implementation) then you will get 30 chars. Just trim them off and carry on. It is nothing to do with dataset; the source of your data has the padding.
 
Back
Top