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
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();
}
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
}