I am trying to work on adding Form Authentication to my ASP.NET app. I try
and gotten Form Authentication with the credentials in the Web.config
file... Now I am going by Jeff Prosise's book "Programming Microsoft .NET"
from Microsoft Press...
In the example there is a function CustomAuthenticate(string username,
string password)...
Here is a snip this code is in the try block...
dataConnection.Open(); //I have try this before with the SqlDataReader
obj and this works...
//Couldn't get StringBuilder to work but that another matter...
string SqlCommandText = "SELECT COUNT (*) FROM USERACCOUNTS WHERE Username =
\'";
SqlCommandText += username; //From CustomAuthenticate() prototype...
SqlCommandText += "\' AND CAST (RTRIM (Password) AS VARBINARY) = CAST (\'";
SqlCommandText += password; //From CustomAuthenticate() prototype...
SqlCommandText += "\' AS VARBINARY)";
SqlCommand dataCommand = new SqlCommand(SqlCommandText, dataConnection);
//Here is where the catch block is jumped more below...
int count = (int) dataCommand.ExecuteScalar();
return (count > 0);
}
In the catch block the debugger says System.Exception.Message = "The text,
ntext, and image data types cannot be compared or sorted, except when using
IS NULL or LIKE operator."...
What am I doing wrong here and why does it work in the book(though I didn't
try the CD example)...
Any help...