Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Dear All,How are you?

now iam importing data from excel sheet this data include employee code, the thing that i need is to get employee_payment and working_days from emp_master table foreach emp_code in datagridview then add them in two new Columns in the data grid view

this is my current code

C#
import_grid.Columns.Add("not_hours_amount", "not_hours_amount");
            import_grid.Columns.Add("hot_hours_amount", "hot_hours_amount");

            string emp_code = string.Empty;
            foreach (DataGridViewRow row in import_grid.Rows)
            {

                emp_code = row.Cells[1].Value.ToString();
                SqlConnection cn =
                new SqlConnection(ConfigurationManager.ConnectionStrings["payroll"].ConnectionString);
                SqlCommand cmd = new SqlCommand("SELECT * FROM [employee_master] WHERE emp_code='" + emp_code + "'", cn);
                cmd.CommandType = CommandType.Text;
                cmd.Connection.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                //More code here
            }


this is my GUI

http://i.imgur.com/qVofbMb.jpg[^]

What I have tried:

import_grid.Columns.Add("not_hours_amount", "not_hours_amount");
import_grid.Columns.Add("hot_hours_amount", "hot_hours_amount");

string emp_code = string.Empty;
foreach (DataGridViewRow row in import_grid.Rows)
{

emp_code = row.Cells[1].Value.ToString();
SqlConnection cn =
new SqlConnection(ConfigurationManager.ConnectionStrings["payroll"].ConnectionString);
SqlCommand cmd = new SqlCommand("SELECT * FROM [employee_master] WHERE emp_code='" + emp_code + "'", cn);
cmd.CommandType = CommandType.Text;
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
//More code here
}
Posted
Updated 30-Jul-16 2:25am

1 solution

any help please with this issue
 
Share this answer
 

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