Im writting a C#, .Net3.5, 3 tier web application with ASP.Net front end, SQL server back-end, interfacing with them via TableAdapters and stored procedures. I've stumbled across some odd functionality. I have a AdminUsers table with columns
UserID int NOT NULL
Username varchar(20) NOT NULL
Hash varchar(50) NOT NULL
Salt varchar(50) NOT NULL
Email varchar(50) NOT NULL
As part of my authentication process for login, I search the table for the supplied username before comparing passwords. This fails because each entry for each varchar column in the table, when returned via the TableAdapter GetData statement, is right padded with spaces to 15 chars ie.
loginUsername = "joe"
storedUsername = "joe
"
Interestingly enough the value stored in the DB is correct, I traced the insertion of a row to ensure this. A Datagrid displaying this table is also displayed correctly. The issue only appears when Im calling the following method,
public static bool CheckIfUsernameAvailable(string username) {
AdminUsersDataTable data = DataCalls.GetAdministers();
foreach (Data.MissionEducate.AdminUsersRow row in data) {
if (row.Username == username) {
return false;
}
}
return true;
}
public static Data.MissionEducate.AdminUsersDataTable GetAdministers() {
AdminUsersTableAdapter tblApt = new AdminUsersTableAdapter();
return tblApt.GetData();
}
And the GetData() basically calls SELECT * FROM AdminUsers
Any suggestions why spaces would be appended to the end of a tableAdapters select commands results? It doesn't seem that the data is stored like this. Do table adapters display this behaviour often? What more information could I provide?
Much thanks.