Link to home
Start Free TrialLog in
Avatar of 32handicap
32handicap

asked on

How do i find out if a value exists in a table in sql compact edition

In C# i want to know if a value exists in a column within a table.  I can't find or figure out the syntax.  I think i am looking for a function that returns the number of rows if found, but i cant find that function for sql compact edition in the class SqlCeCommand.
Thanks,
32Handicap
ASKER CERTIFIED SOLUTION
Avatar of Rahul Goel
Rahul Goel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

may be this query help u

CREATE OR REPLACE FUNCTION F_exist
RETURN boolean IS

BEGIN
 SELECT dept_no, dept_name
   FROM   dept D
   WHERE  EXISTS ( SELECT 'X'
                   FROM   emp E
                   WHERE  E.dept_no = D.dept_no );
  EXCEPTION
  WHEN NO_DATA_FOUND THEN
    RETURN FALSE ;

RETURN TRUE;
END;
/
Avatar of 32handicap
32handicap

ASKER

I tried DataReader.HasRows property and this doesn't work in sql compact edition, "unless you have active cursor", or something like that, (which i do not).  But following along those lines i found I just need to return   reader.Read().  If there is anything to read it will be true, else false.  So i think that will do it unless anybody else has a better way.

 On the other solution, i did not want to do anything that would cause an exception as part of my "normal" code.  

Thanks both for the help

thanks,
32handicap