0

hi can u guys help me find what is my error in my line.

 cmd.CommandText = "SELECT * FROM TblLogin where Username='"+ usr_lgn.Text +"'and Password = '" + pswr_lgn.Text + "'where STAFFSTATUS="+"ACTIVE"+"";

im having an error saying incorrect syntax near the word where.
thank u

4
Contributors
5
Replies
16
Views
2 Years
Discussion Span
Last Post by vijay.soni
0

Shouldn't ACTIVE be surrounded by single quotes? Another issue might be the lack of a space before the WHERE

0

@pritaeas
ok w8 lemme try , ty
edit: still no luck

  cmd.CommandText = "SELECT * FROM TblLogin where Username='"+ usr_lgn.Text +"'and Password = '" + pswr_lgn.Text + "' where STAFFSTATUS='"+"'ACTIVE'"+"'";

Edited by kidkardel: edit

1

A little modification is needed in your SQL statement. It should be the following.

  cmd.CommandText = "SELECT * FROM TblLogin where Username='"+ usr_lgn.Text +"' and Password ='" + pswr_lgn.Text + "' and STAFFSTATUS ='ACTIVE'";
0

@shark_1
never mind THANK YOU!

Edited by kidkardel: eyes

0
cmd.CommandText = string.Format("SELECT * FROM TblLogin WHERE Username='{0}' AND Password = '{1}' AND STAFFSTATUS = '{2}'", usr_lgn.Text, pswr_lgn.Text, "ACTIVE");

Edited by pritaeas: Added markdown.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.