Re: Problem with login code
From: Mark Fitzpatrick (markfitz_at_fitzme.com)
Date: 09/14/04
- Next message: Joerg Jooss: "Re: unique browser session"
- Previous message: Steve C. Orr [MVP, MCSD]: "Re: Problem with login code"
- In reply to: Justin: "Problem with login code"
- Next in thread: Justin: "RE: Problem with login code"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 14 Sep 2004 00:48:37 -0500
Justin,
You may want to look into adding parameters to your query (check out
the SqlParameter object). When you create a string on the fly for a query
and pass it to a command object it's probably suject to a SQL Injection
Attack, which means a moderately skilled hacker could get all the user
accounts by adding some carefully crafted SQL statements into your Email
textbox and have them displayed for him right from your system.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Justin" <Justin@discussions.microsoft.com> wrote in message
news:5A06EBB3-93DC-442C-AF68-8F726E586EEB@microsoft.com...
>I am tring to create a very simple login page that asks for an email
>address
> and password and compares the password entered to the password in the
> accounts table to authenticate the user. I get the following error when
> trying use executereader():
>
> System.Data.SqlClient.SqlException: The column prefix 'asmussen@cableone'
> does not match with a table name or alias name used in the query.
>
> string mySelectQuery = "SELECT AccountID, Email, Password FROM Accounts
> WHERE Email = " + Email.Text;
>
> System.Data.SqlClient.SqlCommand myCommand = new
> System.Data.SqlClient.SqlCommand(mySelectQuery, sqlConnection1);
>
> sqlConnection1.Open();
> myReader = myCommand.ExecuteReader();
>
> if (Password.Text == myReader["Password"])
> {
> Session["Login"] = myReader["Email"];
> Session["AccountID"] = myReader["AccountID"];
> }
> else
> {
> lblStatus.Text = "Login Failed";
> }
>
> myReader.Close();
> sqlConnection1.Close();
>
> Any ideas?
> Thanks, Justin.
- Next message: Joerg Jooss: "Re: unique browser session"
- Previous message: Steve C. Orr [MVP, MCSD]: "Re: Problem with login code"
- In reply to: Justin: "Problem with login code"
- Next in thread: Justin: "RE: Problem with login code"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|