Click here to Skip to main content
13,091,537 members (62,738 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello friends,
I am making report and I have one issue such that when we selecting employee from combobox and run the report then it must show particular employee.
And when I select nothing and run report then all employee from database must be display on what kind of query I should write.
Posted 29-Dec-12 22:52pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

for particular Employee you write where condition in if clause and when you want to all employee information you code normal select query in else clause.............
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

you havent mentioned any code so we have fair idea of your data's. but with that knowledge a sample query may be help you to get going.

you need to write a select query with where condition to filter out the matching employee name. if filter is empty select all.
select * from employeeTable; // this query will return all the rows inside the table employeeTable
select * from employeeTable where EmployeeName = txtFromCombo; // this will return row that matching the EmployeeName equals to the value txtFromCombo where txtFromCombo is a string.
Tejas11C 30-Dec-12 5:54am
no i want two query to be executed at a time(when i select employee it filters that particular employee but if i don't select any employee then it automatically generates reports of all employees means like a if else statements) and i want to write this query in table adapter in visual studio
jibesh 30-Dec-12 6:00am
are you using any stored procedure?
jibesh 30-Dec-12 6:45am
you can use the If else statement in your stored procedure if your using a SP otherwise you need to build a two queries. I dont think that you can have single query with and without where condition.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

//you can get the combo value in this way

if (combo.Text  != "Please Select" && combo.Text  != "All"){
MessageBox.Show("Employee Id is "+ cboItemName.SelectedValue.ToString());
MessageBox.Show("No Employee Select");

May this help you
jibesh 30-Dec-12 5:43am
This is not the right solution for the OPs question. OP is asking about how to prepare the query and not to select the combo.
Ronjon1 30-Dec-12 6:00am
what do you mean i just tell him, how can he get the id from combo box ....
jibesh 30-Dec-12 6:03am
Yes. but thats not what he is asking for. read his question.
'problem related to query' and '... what kind of query i should write'

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100