c# - Check if SELECT statement conditions are true -
string test = "select count(*) table email=@email , active=@active";
hello, possible using c# check if both of conditions true or if 1 of them true?
int count = testcmd.executenonquery();
i have tried using code above not sure understand how works.. count 1 if both conditions true ?
try:
string test = " select count(*) from( select case when (select count(*) table email=@email , active=@active)>0 1 else null end num union select case when (select count(*) table email=@email or active=@active)>0 1 else null end num )x num not null"
which returns 2 if both conditions true, 1 if 1 of them true , 0 if both false.
and use executescalar()
instead of executenonquery()
(which returns number of rows effected).
i.e. int count = (int32)testcmd.executescalar();