public static DataTable docDuLieu(string query) { DataTable table = new DataTable(); SqlConnection con = KetNoiDatabase.ketNoiDatabase(); SqlDataAdapter adap; try { // System.Windows.Forms.MessageBox.Show(query); con.Open(); adap = new SqlDataAdapter(query, con); adap.Fill(table); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); table = null; } con.Close(); return(table); }
public static bool thaoTacDuLieu(string query) { SqlConnection con = KetNoiDatabase.ketNoiDatabase(); SqlCommand cmd = null; bool hopLe = true; try { cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message); hopLe = false; } con.Close(); return(hopLe); }