Click here to Skip to main content
15,921,113 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all of you,

I need help. Please help me.
In my application I have a list box in multiple selection mode. It contains Stream such as Technology, Education, Science, Commerce, Arts and Others. Now I want when user wants to search all the candidates who have taken Technology and Science or all or any single and click on Search button then output should be according to thr user. And if user is not select any one in list box and click on search button then all the candidate info should be display else what he want.
I am doing in asp.net3.5 and Sql Server 2008.

Pleae Give me code.
Posted
Updated 20-Jan-11 19:04pm
v2

1 solution

Well, all you need is a good Query.

Based on the selection, pass on the values to your database layer where you can either use Parameterized Query or Stored Procedure to pullin data. Your query should be in a form that can handle the various scenarios mentioned by you. Give it a try!


Lastly, please avoid sentences like '..give me code.'. It's not good to ask for it until unless you make some effort from your side and share that with us - just a suggestion!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Jan-11 1:19am    
Good answer, my 5.
I like that you try to give OP a chance to learn and understand something. I feel total frustration from "give me code"; and I feel giving code is evil (I mean not always but to this kind of person) because ultimately it would not help anyone, including the inquirer.
Thank you.
--SA
Sandeep Mewara 21-Jan-11 1:24am    
Thanks! :)
c27bharti 21-Jan-11 1:20am    
OK
I am doing it using stored procedure
--------------------SQL SERVER------------------------
------------Here is Part of my stored procedure--------------
rp_tbl_academic_details.prof_qual = @prof_qual And
rp_tbl_academic_details.prof_stream = @prof_stream And
rp_tbl_academic_details.prof_year <= @prof_year And

rp_tbl_academic_details.grad_qual = @grad_qual And
rp_tbl_academic_details.grad_stream = @grad_stream And
rp_tbl_academic_details.grad_year <= @grad_year And


-----------------------ASP.NET(C#)-----------------------------------
string Profess = "Management || Computer Administrative || Diploma Course || Others || Select Stream || || NULL|| ";
string grad = " Technology || Education || Science || Commerce || Arts || Others || Select Stream || || NULL || ";
string PQuali = "M.Tech || MCA || MBA || MA || MBBS || Msc || Msc(IT) || || NULL|| ";
string GQuali = "B.Tech || BCA || BBA || BA || |Bsc || Bsc(IT) || || NULL ||";
string PYear = "2050 || || NULL || 0 ";
string GYear = "2050 || || NULL || 0 " ;



if (txtPQuali.Text != "")
{
PQuali = txtPQuali.Text;
}

if (txtGQuali.Text != "")
{
GQuali = txtGQuali.Text;
}

if (txtPYear.Text != "")
{
PYear = txtPYear.Text;

}

if (txtGYear.Text != "")
{
GYear = txtGYear.Text;

}


if (list_proffQuali.SelectedValue != "0")
{
for (int x = 0; x <= list_proffQuali.Items.Count - 1; x++)
{
if (list_proffQuali.Items[x].Selected == true)
{
Profess = Profess + "" + list_proffQuali.Items[x].Text + "" + ",";
}
}
}

if (Profess != "")
{
Profess = Profess.Substring(0, Profess.Length - 1);
}


//Grad Qualification
if (list_Grad.SelectedValue != "0")
{
for (int x = 0; x <= list_Grad.Items.Count - 1; x++)
{
if (list_Grad.Items[x].Selected == true)
{
grad = grad + "" + list_Grad.Items[x].Text + "" + ",";
}
}
}

if (grad != "")
{
grad = grad.Substring(0, grad.Length - 1);
}
Sandeep Mewara 21-Jan-11 1:33am    
First of all, whats your table structure here?

Ideally it should be:
MstStudents (Has all student name/info only)
MstStreams (Has stream name/info only)
TrbStudentStreams (has info of studentID linked with streamID)

Once you have this in place, you will need to pass on the StreamID searched for (nothing in case of nothing selected). Make the query in SP such that you can use the passed StreamID(s) and find the studentID's first from TrnStudentStreams table (and then moving on to their names).

Do it step wise.

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