Solved

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

Posted on 2009-07-05
4
179 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that useā€¦
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

729 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