473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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

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

Nov 15 '05 #1
2 1241
That is a SQL error.

change your field's datatype to varchar(50) instead of ntext or whatever you
have it as.

you'll also want to potentially index that field, and text/ntext fields
cannot be indexed.
--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]

"lewi" <bj******@willapabay.org> wrote in message
news:vt************@corp.supernews.com...
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...

Nov 15 '05 #2
Thanks Eric for your great help. Works correctly now. in the mentioned book,
configuring the DB table was done with scripts and I setup my own db
table...

Well thanks again...


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dfdfd | last post by:
I have a MSDE database that I am trying to connect to with JDBC. I don't have SQL Server installed. Is this possible? When I try to connect I get the error: java.sql.SQLException: Login...
0
by: mkoleno346 | last post by:
If I want to change autentication modes for an instance of MSDE that I already installed, what is the best way to go about this? I don't think you can change authentication modes using any of the...
5
by: lewi | last post by:
I am just starting to use ASP.NET(C#) with VS.NET 2002 Pro on Win2000 Server and spend only little time with MySQL while working with PHP. Now I am only using all this for developement/learning and...
1
by: lewi | last post by:
I am trying to connect to MSDE hosted DB on the same computer as my ASP.NET app. The DB was created using VS.NET Server Explorer window and here is my aspx.cs code in the Page_Load() for the main...
0
by: lewi | last post by:
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...
4
by: Anthony P. Mancini | last post by:
Does anyone know how to make the MSDE do SQL authentication ? It appears to authenticate using Windows at all times. Thanks, Anthony
1
by: NWx | last post by:
Hi, I'm an old developer, but didn't used SQL Server or MSDE to much before. I have NetSDK instance of MSDE installed on my PC by Net Framework SDK. All quickstart samples access it using...
7
by: John Blair | last post by:
Hi, I am trying to get the datacache1 sample working on my PC. I have downloaded the MSDE 2000 sample SQL Server database and the pubs sample database and installed it. I can view the contents...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.