Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The informations are stored in diff tables of a database. For instance DB name say DB1. It has tables such as task,story,person,... I want to check the condition as if task.acceptor_id and story.owner_id=person.userId, then name of the task and story should be displayed in the particular user's page.
I also want to display the details of the tasks/story for a user/dev in a project website checking the condition that the user/developer is only assigned to any task/story of the project. Or it should not be display any tasks/story related information in his/her page.
should be done in C#
Please help me to finish it.
Thanks in advance...
Posted
Comments
Sampath Kumar Sathiya 24-Dec-12 5:05am    
Have you tried anything, Please give those details?
[no name] 24-Dec-12 5:27am    
"should be done in C#" Does this mean you want to do the above task using C# only with out any sql server involvement?
Zoltán Zörgő 24-Dec-12 5:29am    
This is not a "quick answers" kind of question. Much like a whole project. Nobody will be able or willing to do the job for you. You have to try to solve by yourself, and if you get lost somewhere, and you have a really concrete question in a really concrete situation, you can come back, and we will be willing to help you - and most likely able to help you if it is possible.
You have not even specified if you want to make a thick (windows forms) or thin (asp.net) application...

1 solution

Try using an SQL JOIN:
SQL
SELECT t.Name, s.Name FROM person p
JOIN story s ON p.userId=s.owner_id
JOIN task t ON p.userId=t.acceptor_id
All you have to do is package it in C# code:
C#
using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand com = new SqlCommand("SELECT t.Name AS task, s.Name AS story FROM person p JOIN story s ON p.userId=s.owner_id JOIN task t ON p.userId=t.acceptor_id", con))
        {
        using (SqlDataReader reader = com.ExecuteReader())
            {
            while (reader.Read())
                {
                string task = (string) reader["task"];
                string story = (string) reader["story"];
                Console.WriteLine("{0}, {1}", task, story);
                }
            }
        }
    }
 
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