Quote Originally Posted by NFSRacer View Post
Okay, but I tried without the NULL check box in the table design checked and got that same result. However querying the entire table means I'd have to do a ToArray to be able to use the data, right? I mean, how can I access the password and username independantly?

UPDATE:
I do remember doing another debugging session a while back to see what the issue was, and found the string being returned in each of the queries was the column name, rather than anything else! I mean, as far as I understand it in the query, it's returning a table, but the ToString is supposed to turn the only value on that table into a string to be compared, the GetUserName searching for and returning that username in the database, and the GetPassword returning the password associated with that username. The column that keeps getting returned I named 'login', and each time I tried, it came back with that string, instead. Could that be it?
It's not the column name. It's the table name. That's what happens when you call ToString on a DataTable: you get the value of its TableName property. The fact that you want it to do something else is irrelevant because that's what it does. The fact that you thought it was a column name is perfect example of why it's extremely poor practice to give a table and a column in that table the same name. Like I said, there's a lot to fix in that code.

Look, all you need to do is a single query. If you're going to populate a DataTable then you need to get both the user name and password columns because they're both non-nullable but if you're just going to get a value then you only need the password because you've already got the user name. You first need to decide which way you want to go. If you go the first way then your DataTable will contain zero or one record and if you go the second way you will get either a value or NULL.