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
Thanks,
32Handicap
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
thanks,
32handicap
32handicap
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;
/