Problem is still unidentified. What actually you want to achieve, a new row or update an existing row.
In case of insert:
using( var command1 = new SqlCommand("INSERT INTO Employee(EmpPhone,Password,OfficeNo,Floor, Building) VALUES (@EmpPhone,@Password,@OfficeNo,@Floor, @Building)", con))
{
command1.Parameters.AddWithValue("@EmpPhone", Convert.ToInt32(phone.Text));
command1.Parameters.AddWithValue("@Password", password.Text);
command1.Parameters.AddWithValue("@OfficeNo", officeNo.Text);
command1.Parameters.AddWithValue("@Floor", Convert.ToInt32(floor.Text));
command1.Parameters.AddWithValue("@Building", Convert.ToInt32(building.Text));
int i= command1.ExecuteNonQuery();
}
Update:
using( var command1 = new SqlCommand("Update Employee Set EmpPhone=@EmpPhone,Password=@Password,OfficeNo=@OfficeNo,Floor=@Floor, Building = @Building Where EmployeeId =@Id", con))
{
command1.Parameters.AddWithValue("@EmpPhone", Convert.ToInt32(phone.Text));
command1.Parameters.AddWithValue("@Password", password.Text);
command1.Parameters.AddWithValue("@OfficeNo", officeNo.Text);
command1.Parameters.AddWithValue("@Floor", Convert.ToInt32(floor.Text));
command1.Parameters.AddWithValue("@Building", Convert.ToInt32(building.Text));
command1.Parameters.AddWithValue("@Id", Convert.ToInt32(Id.Text));
int i= command1.ExecuteNonQuery();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…