Cukup ubah SqlCommand.CommandText
alih-alih membuat SqlCommand
baru setiap saat. Tidak perlu menutup dan membuka kembali koneksi.
// Create the first command and execute
var command = new SqlCommand("<SQL Command>", myConnection);
var reader = command.ExecuteReader();
// Change the SQL Command and execute
command.CommandText = "<New SQL Command>";
command.ExecuteNonQuery();