I'm not sure why this is, basically when I insert a row using the following function:
public bool CreateUser(string username, string password, string email, int age = 0)
{
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = "Data Source=localhost\\SQLEXPRESS;" +
"Initial Catalog=Pubs;Integrated Security=SSPI;Trusted_Connection=True;";
try
{
myConnection.Open();
string query = "INSERT INTO SiteUser VALUES('" + username + "', '" + password + "', '" + email + "', " + age + ")";
SqlCommand cmd = new SqlCommand(query);
cmd.Connection = myConnection;
cmd.ExecuteNonQuery();
myConnection.Close();
}
catch (Exception excep)
{
string error = excep.ToString();
Response.Write(error);
return false;
}
return true;
}
The field 'Password' ends up having white spaces in it (as in "Password "). So whatever the password is it's trailed by white spaces.
The strange thing is this doesn't happen to the field 'UserName', both are of type char(50).