I have made a form for searching purpose.
where
1. eight Combobx with 8 Values/Items (table Column Names)
2. one TextBox
3. another Combobx with two option (AND/OR)
the above 3 line group is eight time in my forms.
i have also place a checklist box with six option
now i am going to make searching query.
here is the query
string SearchQuery = "Select * From Hadiths_old Where Baab_Id < 100 =" + BookSelection + AndOrQuery ;
here BookSelection Query Fragment Formation, this is one the basis of checklist box item selection
string BookSelection = "";
if (clbBooksName.GetItemChecked(0) == true)
{
BookSelection = "OR Hadith_Book_Number = 1";
}
if (clbBooksName.GetItemChecked(1) == true)
{
BookSelection = "OR Hadith_Book_Number = 2";
}
if (clbBooksName.GetItemChecked(2) == true)
{
BookSelection = "OR Hadith_Book_Number = 3";
}
if (clbBooksName.GetItemChecked(3) == true)
{
BookSelection = "OR Hadith_Book_Number = 4";
}
if (clbBooksName.GetItemChecked(4) == true)
{
BookSelection = "OR Hadith_Book_Number = 5";
}
if (clbBooksName.GetItemChecked(5) == true)
{
BookSelection = "OR Hadith_Book_Number = 6";
}
Now for Combox of Column and AND/OR Operator. I am really stuck
8 combobox values with one text box and then also another combobox with two values (and/or)
i try to make this query
if(!String.IsNullOrEmpty(tbSearch1.Text) && cbColumn1.SelectedIndex ==0 && cbOperator1.SelectedIndex==0)
{
AndOrQuery = "AND Hadith_Arabic ="+ tbSearch1.Text + "AND";
}
may be this will work but i am really worry if i use this techniques then i need to make lot of condition maybe 50 or 100 condition which is not possible. please help here.
how to form query??