Click here to Skip to main content
15,910,980 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SELECT * From sec_users_ids where UserName = ('"+ userName +"')"

i am passing a querry to command.commandtext(str_querry) ant then command.executenonquerry()
how i come to know that that particular data is present there or not
i already created connection and .......
Posted

try this

SELECT count(*) From sec_users_ids where UserName = ('"+ userName +"')"

int i = Convert.ToInt32(command.ExecuteScalar());

if ( i == 0)
   //User does not exist
else
   //User exist
 
Share this answer
 
Comments
kami124 6-Jul-11 2:34am    
thanks
hello,

one way of doing this is take data into a datatable using sqladapter and then check a condition for rowcount if count is greater than 0 that means data is there.


thanks
sanjeev
 
Share this answer
 
to get the record you may use datareader instead of executenonquery
 
Share this answer
 
If you want jsut to find if the user exists, change the sql to

Select count(*) from ....

then the result of your executenonquery will be the number of rows found

e.g.

int x = command.executenonquery

then check x
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900