Solved

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

Posted on 2009-07-05
4
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Rahul Goel ITIL 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
subtr returning incorrect value 8 65
Trouble with <> 2 26
MS SQL GROUP BY 6 75
error in oracle form 11 22
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.‚Äč
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

756 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