C
Carlo Razzeto
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
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