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

Recommended Answers

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

Jump to Post

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'";
Jump to Post

All 5 Replies

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

@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'"+"'";

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'";

@shark_1
never mind THANK YOU!

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

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.