Multiple Html Textbox values insertion
protected void Button1_Click(object sender, EventArgs e)
{
string firstname = Request.Form["txtfname"];
string lastname = Request.Form["txtlname"];
string EmpCode = Request.Form["txtempcode"];
string Position = Request.Form["txtpos"];
string Office = Request.Form["txtoff"];
SqlConnection conn = new SqlConnection(@"Persist Security Info=False;User ID=sa;Password=1234;Initial Catalog=sujay;Data Source=IBTSYS13\SQLEXPRESS");
conn.Open();
//SqlCommand cmd = new SqlCommand("INSERT INTO Employee(firstname),(lastname),(EmpCode),(Position),(Office) VALUES(@firstname),(@lastname),(@EmpCode),(@Position),(@Office)", conn);
SqlCommand cmd = new SqlCommand("INSERT INTO Employee(firstname,lastname,EmpCode,Position,Office) VALUES( @firstname,@lastname,@EmpCode,@Position,@Office)", conn);
//SqlCommand cmd = new SqlCommand("INSERT INTO Employee(firstname)VALUES(@firstname)", conn);
cmd.Parameters.AddWithValue("@firstname", firstname);
cmd.Parameters.AddWithValue("@lastname", lastname);
cmd.Parameters.AddWithValue("@EmpCode", EmpCode);
cmd.Parameters.AddWithValue("@Position", Position);
cmd.Parameters.AddWithValue("@Office", Office);
//conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
// String s = "Insert into Employee values('" + txtfname + "','" + txtlname + "','" + txtempcode + "','" + txtpos + "','" + txtoff + "')";
//// SqlCommand cmd = new SqlCommand(s, conn);
// cmd.ExecuteNonQuery();
}