how i insert values from list of Data Grid View?

Posted by Six fourty on Stack Overflow See other posts from Stack Overflow or by Six fourty
Published on 2010-03-27T12:59:49Z Indexed on 2010/03/27 13:43 UTC
Read the original article Hit count: 271

Filed under:
|

it show me this error Incorrect syntax near the keyword 'Select' to make to clear Employee ID in this case is FK in the table (Attendance detail) and the other thing is i am using Data Grid View from another table(Employee information) to Show the list of the staff in my form. then i want to transfer each selected cell value from Data Grid View to attendance detail table. 10q

    private void time_in_Click(object sender, EventArgs e)
    {
        employee_InformationDataGridView.SelectedCells[0].Style.ForeColor = Color.Green;

            time_in.Enabled = false;
            time_out.Enabled = true;

            con = new SqlConnection(GlobalClass.conn);
            con.Open();
            SqlCommand cmd = new SqlCommand("Insert into Attendancedetail  Values(" + "Select from  EmployeeInformation(EmployeeID)" + ",'" + employee_InformationDataGridView.SelectedCells[0] + "','" + DateTime.Now.ToLongDateString() + "','" + null + "','" + null + "','" + DateTime.Now.ToLongTimeString() + "'," + null + ")", con);
            int i = cmd.ExecuteNonQuery();
            MessageBox.Show(i.ToString() + " record inserted");
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about ADO.NET