C#/ADO adding spaces to varchar??

  • Thread starter Thread starter Rene
  • Start date Start date
R

Rene

Hi,

I'm reading a table with fields of varchar type and the
DataReader["MyField"].ToString returns the field padded with spaces upto the
maximum length. In QA select len(MyField) returns a different length for
each field and for sure I ran an update with RTRIM() for each row.

I'm using SqlDataReader.

TIA,

Rene
 
Rene said:
Hi,

I'm reading a table with fields of varchar type and the
DataReader["MyField"].ToString returns the field padded with spaces upto the
maximum length. In QA select len(MyField) returns a different length for
each field and for sure I ran an update with RTRIM() for each row.

I'm not sure I understand the problem. Are you saying that with a Reader
the lenght of the field returned with DataReader.GetString["MyField"] is 50
or some other constant that's equal to the field lenght? I've done this a
bunch and just ran another test and I'm getting only the lenght of the
field. Perhaps you have spaces contained in the field itself. Anyway, let
me confirm the problem before we look at a solution.
I'm using SqlDataReader.

TIA,

Rene

--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top