Click here to Skip to main content
15,885,914 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Retrieve the value of a control of the master page Pin
amina894-Apr-11 12:08
amina894-Apr-11 12:08 
AnswerRe: Retrieve the value of a control of the master page Pin
Prasanta_Prince14-Apr-11 1:10
Prasanta_Prince14-Apr-11 1:10 
Questionproblem in displaying the data in datagrid` Pin
manikumar_gutti31-Mar-11 23:14
manikumar_gutti31-Mar-11 23:14 
AnswerRe: problem in displaying the data in datagrid` Pin
Deshpande.anagha1-Apr-11 0:43
Deshpande.anagha1-Apr-11 0:43 
AnswerRe: problem in displaying the data in datagrid` Pin
ktrrzn5-Apr-11 15:18
ktrrzn5-Apr-11 15:18 
QuestionCaptcha and Client IP Pin
Priya Prk31-Mar-11 22:57
Priya Prk31-Mar-11 22:57 
AnswerRe: Captcha and Client IP Pin
L Viljoen31-Mar-11 23:09
professionalL Viljoen31-Mar-11 23:09 
QuestionA login problem Pin
Farhad Eft31-Mar-11 20:49
Farhad Eft31-Mar-11 20:49 
Hi

Can anybody help me please.
when i try to login in my asp.net 4 page with the following source code an error returns:


        DataTable dt = new DataTable();<br />
        DataSet ds = new DataSet();<br />
        SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["SN11ConnectionString"].ConnectionString);<br />
        SqlCommand sqlCmd = new SqlCommand("SELECT UserId FROM [Users] WHERE ([Email]=@Email AND [Password]=@Password", sqlConn);<br />
        //Create the parameters<br />
        SqlParameter paramEmail;<br />
        paramEmail = new SqlParameter("@Email", SqlDbType.NVarChar, 25);<br />
        paramEmail.Value = TextBoxLoginEmail.Text;<br />
        sqlCmd.Parameters.Add(paramEmail);<br />
<br />
        //Hash the password<br />
        MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();<br />
        byte[] hashedBytes;<br />
        UTF8Encoding encoder = new UTF8Encoding();<br />
        hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(TextBoxLoginPassword.Text));<br />
        SqlParameter paramPwd;<br />
        paramPwd = new SqlParameter("@Password", SqlDbType.Binary, 16);<br />
        paramPwd.Value = hashedBytes;<br />
        sqlCmd.Parameters.Add(paramPwd);   <br />
<br />
            sqlConn.Open();<br />
            SqlDataAdapter sda = new SqlDataAdapter(sqlCmd);<br />
            sda.Fill(ds);<br />
            dt = ds.Tables[0];


Here is the error message that appears when i press the login button:

Incorrect syntax near '@Password'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near '@Password'.

Source Error:

Line 57: sqlConn.Open();
Line 58: SqlDataAdapter sda = new SqlDataAdapter(sqlCmd);
Line 59: sda.Fill(ds);
Line 60: dt = ds.Tables[0];
Line 61: }


Thank you.
AnswerRe: A login problem Pin
Venkatesh Mookkan31-Mar-11 21:01
Venkatesh Mookkan31-Mar-11 21:01 
GeneralRe: A login problem Pin
Farhad Eft31-Mar-11 21:24
Farhad Eft31-Mar-11 21:24 
AnswerRe: A login problem Pin
C#Coudou31-Mar-11 21:02
C#Coudou31-Mar-11 21:02 
GeneralRe: A login problem Pin
Farhad Eft31-Mar-11 21:23
Farhad Eft31-Mar-11 21:23 
GeneralRe: A login problem Pin
Farhad Eft31-Mar-11 21:26
Farhad Eft31-Mar-11 21:26 
GeneralRe: A login problem Pin
C#Coudou3-Apr-11 22:13
C#Coudou3-Apr-11 22:13 
AnswerRe: A login problem [modified] Pin
davidnz2-Apr-11 10:57
davidnz2-Apr-11 10:57 
AnswerRe: A login problem Pin
SamRST4-Apr-11 21:19
SamRST4-Apr-11 21:19 
QuestionProblem with a require input field DropDownList if old records have null in this field Pin
kbalias31-Mar-11 20:42
kbalias31-Mar-11 20:42 
AnswerRe: Problem with a require input field DropDownList if old records have null in this field Pin
ktrrzn5-Apr-11 15:39
ktrrzn5-Apr-11 15:39 
QuestionHelp how to get the list of printer in the client computer Pin
C#Coudou31-Mar-11 15:17
C#Coudou31-Mar-11 15:17 
AnswerRe: Help how to get the list of printer in the client computer Pin
Not Active31-Mar-11 16:59
mentorNot Active31-Mar-11 16:59 
GeneralRe: Help how to get the list of printer in the client computer Pin
C#Coudou31-Mar-11 18:07
C#Coudou31-Mar-11 18:07 
GeneralRe: Help how to get the list of printer in the client computer Pin
Not Active1-Apr-11 0:59
mentorNot Active1-Apr-11 0:59 
Questiondocument.getElementById Not work With Masterpage ASP.Net VB Pin
Diyaa Hamza31-Mar-11 10:02
Diyaa Hamza31-Mar-11 10:02 
AnswerRe: document.getElementById Not work With Masterpage ASP.Net VB Pin
El_Programmer31-Mar-11 10:53
El_Programmer31-Mar-11 10:53 
GeneralRe: document.getElementById Not work With Masterpage ASP.Net VB Pin
Diyaa Hamza31-Mar-11 11:01
Diyaa Hamza31-Mar-11 11:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.