Quest: Problem with Form Authentication w/ from MSDE SQL DB...

L

lewi

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top