Solved

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

Posted on 2009-07-05
4
172 Views
Last Modified: 2013-12-07
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
0
Comment
Question by:32handicap
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Rahul Goel earned 500 total points
ID: 24782925
See, you need to check for the DataReader.HasRows property.
Aftere execulting the SQLCommand you will be retrieving resultset. get the DataReader and check with the property mentioned
0
 
LVL 14

Expert Comment

by:shru_0409
ID: 24784109

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;
/
0
 

Author Comment

by:32handicap
ID: 24791177
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

0
 

Author Closing Comment

by:32handicap
ID: 31600030
thanks,
32handicap
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now