Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have 3 check boxes of years, 2008, 2009, 2010
i have a database in sql server, i have to generate reports like %age of employees, gender wise employees etc,
i have to generate same reports on the basis of these check boxes, one, two or three values should generate same reports,
what should i do/ study to do so
Posted
Comments
dan!sh 22-Jul-11 3:12am    
Is this a windows form application or a web based one? Or are you trying to use SSRS?
Db issues 23-Jul-11 0:13am    
this is a desktop application, im using dotenet and C#
Db issues 23-Jul-11 0:13am    
with sql

Pass the selected years as comma separated values to your stored procedures like this '2008,2009,2010'. In the Stored Procedure, build a dynamic query using this input in the WHERE clause like this
SQL
' WHERE MyYear IN (' + @SelectedYears + ')'
 
Share this answer
 
i have a logic , and asking about how can we dolike a session variable,
if year is 2008, than it will load database data into temporary database table and calculate reports from that data, and so on for the 2009 and 2010
 
Share this answer
 
select * from table where year in (2008,2009.2010) pass the year at run time when u write query
 
Share this answer
 
Comments
Db issues 23-Jul-11 13:47pm    
i have almost 34 reports for each year, and for any two of them or selecting all
if coulmn is varchar()
step 1:

declear a varibles

string s; on class

step 2:

C#
private void checkBox1_CheckedChanged(object sender, EventArgs e)
       {

           if(checkBox1.Checked==true)
           {
             this.s = checkBox1.Text;
           }
       }

       private void checkBox2_CheckedChanged(object sender, EventArgs e)
       {
           if (checkBox2.Checked == true)
           {
               this.s = checkBox2.Text;
           }
       }

       private void checkBox3_CheckedChanged(object sender, EventArgs e)
       {
           if (checkBox3.Checked == true)
           {
               this.s = checkBox3.Text;
           }
       }


step 3:

your command text="select * from employee where year= ' " + this.s + " ' ";
 
Share this answer
 
Comments
Db issues 28-Jul-11 2:35am    
Thanks, highly obliged
Might help,

C#
public Action<string> DataSelection = new Action<string>((data) =>
{
    string sqlCommandText = "Select * From YearTable Where Year='" + data + "';";
    // Do the database query execution bit in here.
});

protected void cb2008_CheckedChanged(object sender, EventArgs e)
{
    if (cb2008.Checked)
        DataSelection(cb2008.Text);
}

protected void cb2009_CheckedChanged(object sender, EventArgs e)
{
    if (cb2009.Checked)
        DataSelection(cb2009.Text);
}

protected void cb2010_CheckedChanged(object sender, EventArgs e)
{
    if (cb2010.Checked)
        DataSelection(cb2010.Text);
}


Hope it helps :)
 
Share this answer
 
Comments
Db issues 28-Jul-11 2:36am    
this soln also applied, i'll implement and ask further if any query. thanks anyway

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