Marina is right. We rarely use Char anymore for anything except those fields
where we know the length will ALWAYS be a fixed number of characters. This
is handy for part numbers or somesuch but anytime you're working with a
field that varies in length, use a VarChar. In the "olden days", we often
looked for small ways to help reduce the size of the DB and using CHAR made
more sense back then. Nowadays it's more trouble than it's worth to use
CHAR.
hth
--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"Marina" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> When you define a columns as char(15), that means there will always be 15
> characters in that field. If you put anything smaller in, it will be
padded
> with spaces such so the field is always 15 in length. So if your string
has
> 12 character, there will be 3 spaces afterwards.
>
> If you do not want this behavior, use a varchar(15) type. This holds up
to
> 15 characters, but does not pad with spaces.
>
> "Carlo Razzeto" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Table is setup as follows
> > UserData
> > UserName char(15)
> > Password char(15)
> > UserLevel tinyint
> >
> > Carlo
> >
> > "Marina" <(E-Mail Removed)> wrote in message
> > news:ei%(E-Mail Removed)...
> > > What data type is the column set to in sql server? Is it a char or
> > varchar?
> > >
> > > "Carlo Razzeto" <(E-Mail Removed)> wrote in message
> > > news:%(E-Mail Removed)...
> > > > First of all, sorry about cross posting but I wasn't sure which
group
> > this
> > > > question was more appropriate for...
> > > >
> > > > I am having a problem with Microsoft SQL Server or SqlDataReader
(most
> > > > likely the former) apparently appending white space to the end of
> > database
> > > > results... The code I have looks like:
> > > >
> > > > Dim ConnectionString = "Data Source=(local); User=sa;
> > > Password=Oper64Hammer;
> > > > Initial Catalog=my_work"
> > > > Dim Query = "SELECT UserName, PassWord, UserLevel FROM UserData
WHERE
> > > > UserName = '" + user + "'"
> > > > Dim SQLConnection As New SqlConnection(ConnectionString)
> > > > SQLConnection.Open()
> > > > Dim Command As New SqlCommand(Query, SQLConnection)
> > > > Dim Reader As SqlDataReader = Command.ExecuteReader()
> > > >
> > > > For some reason when I read from the password column of the result
set
> I
> > > get
> > > > the password with with one black space appended to the end of the
> > string.
> > > > This forced me to write store my password in a string then use the
> > > > string.trim method to remove the white space so I could accurately
> > compare
> > > > the database result to the password entered by the user. What causes
> > this
> > > > problem? And is there any way to correct it? I would hate to have to
> > store
> > > > all my database results as strings so I can trim them when ever I
need
> > to
> > > > compare results to user input. Thanks for any help,
> > > >
> > > > Carlo
> > > >
> > > >
> > >
> > >
> >
> >
>
>