Click here to Skip to main content
15,891,739 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
this is c# code , give me error incorrect syntax near & .
any help please .


C#
cmd.CommandText = "select username , password from passwords where username='"
                    + textBox1.Text + "' && password='" + textBox2.Text + "'";
                object obj = cmd.ExecuteScalar();

                if (obj == null) // No such username or password exist
                    label5.Text = "NotValid";
                else
                {
                    label5.Text = "Valid";
                }
Posted

1 solution

Your Question is about SQl Query you need to change AND instead of &&


C#
cmd.CommandText = "select username , password from passwords where username='"
                    + textBox1.Text + "' and  password='" + textBox2.Text + "'";
 
Share this answer
 
v2
Comments
Maciej Los 22-Dec-14 4:32am    
+5
King Fisher 22-Dec-14 4:37am    
Thank you, but not that much complicated question i solved. :laugh:
King Fisher 22-Dec-14 4:43am    
merry christmas :) Maceij
Maciej Los 22-Dec-14 5:31am    
Thank you, and for you too ;)
CPallini 22-Dec-14 4:36am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900