public static SqlInt32 InsertCrew(SqlString Lastname, SqlString Firstname, SqlInt32 Age, SqlInt32 DepartmentID, SqlInt32 CityID, SqlString Job, SqlInt32 ClassID) { Crew newCrew = new Crew(Firstname, Lastname, Age, DepartmentID, CityID, Job, ClassID); if (newCrew.CheckInputs() == false) { return(0); } using (SqlConnection conn = new SqlConnection("context connection=true")) { SqlCommand comm = new SqlCommand(); comm.CommandText = "INSERT INTO Crew ( Lastname, Firstname, Age, DepartmentID, CityID, Job, ClassID) VALUES (@Lastname, @Firstname, @Age, @DepartmentID, @CityID, @Job, @ClassID)"; comm.Connection = conn; foreach (var param in newCrew.paramList) { comm.Parameters.Add(param); } conn.Open(); comm.ExecuteNonQuery(); conn.Close(); conn.Dispose(); comm.Dispose(); return(1); } }