I have a employee table which contains employee information and a Contact details table which contains the phone numbers of the employees. the employees have more than 2 phone numbers.
now, to display the employee information, i have a datagrid. what i want to do is display the first 2 numbers along with the employee information in the datagrid.
i use the following method to fill the data grid
public static void SignUpControllerDay(DateTime Date, System.Windows.Forms.DataGridView PassedGrid)
{
string sql_SignUp = String.Format(@"SELECT e.Emp_ID as Emp_ID,
e.First_Name+ ' ' +e.Last_Name as Name,
sum(o.Quantity) as Sum
FROM Employee e,OT_hours o,Position p,Signup_Sheet s
WHERE e.Emp_ID=o.Emp_ID
and e.Emp_ID = s.Employee_ID
and s.Day_Shift = 1
and e.Position_ID = p.Position_ID
and p.Position_Name = 'Controller'
and o.Quantity NOT IN(0.3)
and s.Date = '{0}'
and o.Date <= CONVERT(VARCHAR,'{0}',101) AND o.Date > CONVERT(VARCHAR,DATEADD(YYYY,-1,'{0}'),101)
GROUP BY e.Emp_ID,e.First_Name+' '+e.Last_Name,p.Position_Name
ORDER BY Sum", Date);
SqlConnection sqlConn = null;
SqlCommand cmd_SignUp;
SqlDataReader dr_SignUp;
try
{
sqlConn = new SqlConnection(databaseConnectionString);
sqlConn.Open();
cmd_SignUp = new SqlCommand(sql_SignUp, sqlConn);
dr_SignUp = cmd_SignUp.ExecuteReader();
while (dr_SignUp.Read())
{
PassedGrid.Rows.Add(dr_SignUp["Emp_ID"].ToString(), dr_SignUp["Name"].ToString(), dr_SignUp["Sum"].ToString());
}
}
catch (Exception e)
{
MessageBox.Show("Error found in SignUpControllerDay..." + Environment.NewLine + e.ToString());
}
finally
{
if (sqlConn != null)
{
sqlConn.Close();
}
}
}
the above method displays the empid,name,sum of the employees. all i want to do is display any 2 phone numbers from the contact_details table. i tried using a data reader to get the phone numbers based on the employee id, but it did not work.
please help....