Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am taking username and rolename from users and groups table respectively and

i have a third role table which has a foreign key of userid and groupid from the users table and groups table.

now i want to assing roles to users on the bases of username and rolename if it doesnot exits in the database. but first i am checking that whether the role exits or not in the role table of the database.

so i write a query to implement it. its not executing properly


<pre lang="c#">"SELECT Count(UserId,GroupID) FROM roles Select UserId,GroupID from Users,Groups WHERE username = '" + TextBox1 + "' AND name = '" + TextBox2.Text + "'";


can anyone help me to correct it out.
Posted
Comments
nagendrathecoder 8-Sep-11 8:24am    
Have you tried my solution before downvoting it?
If yes then update your question and also tell us what error you are getting.
codegeekalpha 8-Sep-11 8:27am    
i did not downvote it... i gave it five now..

1 solution

Try
Count(UserID) or Count(*)
 
Share this answer
 
Comments
codegeekalpha 8-Sep-11 8:31am    
thx negendrathecoder
my five for u...
codegeekalpha 8-Sep-11 8:34am    
i used count * . now its saying all the time that record exits..

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