public void postPostalPlace(PostalPlace PostalPlace) { AddPostalPlaceForQuerry( "insert into poststed(poststed, postnr) values(@PostalPlace.PostalPlace, @PostalPlace.PostalNumber);", PostalPlace ); }
public void UpdatePostalPlace(int id, PostalPlace PostalPlace) { AddPostalPlaceForQuerry( "update poststed set [email protected] where postnr=" + id.ToString() + ";", PostalPlace ); }
private void AddPostalPlaceForQuerry(string command, PostalPlace PostalPlace) { using (MySqlConnection conn = new MySqlConnection(ConnectionString)) { conn.Open(); MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = command; cmd.Parameters.AddWithValue("@PostalPlace.PostalPlace", PostalPlace.PostPlace); cmd.Parameters.AddWithValue("@PostalPlace.PostalNumber", PostalPlace.PostalNumber); cmd.ExecuteNonQuery(); conn.Close(); } }