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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.