how to get all employee id in to single variable?

.net , asp.net Chile
  • 12 years ago

    I am using .net 2005.i am doing my project in asp.net.my project title is master log attendance.how to get all employee id in to single variable?

    We have got employee id from single table by using single variable.but the datas are displayed for final id only.but we want to get more employee id from single variable.

    The following code


    protected void img_submit_Click(object sender, ImageClickEventArgs e)
    {
    from_date = txt_fr_date.Text;
    to_date = txt_to_date.Text;
    emp_name = ddl_emp_name.SelectedValue;
    check();
    }
    void check()
    {

    System.TimeSpan dt_diff = Convert.ToDateTime(to_date).Subtract(Convert.ToDateTime(from_date));
    days = dt_diff.Days;


    dt.Columns.Add(new DataColumn("ID", typeof(string)));
    dt.Columns.Add(new DataColumn("Name", typeof(string)));

    string empid1;
    com = new SqlCommand("select distinct(emp_id) from tbl_report", con);
    dr = com.ExecuteReader();
    while (dr.Read())
    {

    empid1 = dr.GetString(0);

    }
    dr.Close();
    for (int i = 0; i <= days; i++)

    {
    sql_date = Convert.ToDateTime(from_date).AddDays(i).ToString("MM/dd/yyyy");
    sql_date1 = Convert.ToDateTime(from_date).AddDays(i).ToString("MM/dd/yyyy");


    dt.Columns.Add(new DataColumn(sql_date1, typeof(string)));
    drow = dt.NewRow();




    com = new SqlCommand("select distinct rpt.emp_id as EmployeeID,card.username as EmployeeName,min(case when rpt.datetime1='" + sql_date + "' then rpt.datetime1 end) as '" + sql_date + "' from tbl_card as card,tbl_report as rpt where card.fkdata=rpt.emp_id and rpt.datetime1='" + sql_date + "' and emp_id='" + empid1 + "' group by rpt.emp_id,card.username", con);
    dr = com.ExecuteReader();
    while (dr.Read())
    {
    drow[0] = dr.GetString(0);
    drow[1] = dr.GetString(1);

    drow[i+2] ="x";
    dt.Rows.Add(drow);
    }
    dr.Close();


    }



    GV_musterrole.DataSource = new DataView(dt);
    GV_musterrole.DataBind();

    }

    in above code,i get all employee id into variable name as empid1.then i put empid1 for employeeid field in where condition of query in for loop.
    but displayed only one employee id as follow in grid view,

      ID   Name   10/11/2007 10/12/2007 10/13/2007 10/14/2007  10/15/2007
     370 ramesh                                                          x

    so i want to get all employee id into single variable name as empid1.then put empid1 for employeeid field in where condition of query means,i want to come all employee id details as follow.
    ID   Name   10/11/2007 10/12/2007 10/13/2007 10/14/2007 10/15/2007
    366 dinesh                        x               x                x
    367 ram                            x
    369 guru                           x                                 x
    370 ramesh                                                         x

  • 12 years ago

     Hi,

     

       Get Employee id also in the array variable. A normal variable can store only one variable at a time.so try with array .

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perl - The only language that looks the same before and after RSA encryption.” - Keith Bostic