Exemplo n.º 1
0
 public void UpdateTable()
 {
     con = new BDConnection("Students", "127.0.0.1", "3306", "root", "");
     con.OpenConnection();
     conMy   = con.returnCell();
     ds      = new DataSet();
     adapter = new MySqlDataAdapter("SELECT * FROM students", conMy);
     adapter.Fill(ds);
     dataGridView1.DataSource = ds.Tables[0];
     ds.Tables.Clear();
     con.CloseConnection();
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            con = new BDConnection("Students", "127.0.0.1", "3306", "root", "");
            con.OpenConnection();
            conMy   = con.returnCell();
            ds      = new DataSet();
            adapter = new MySqlDataAdapter("INSERT INTO students.students(data, name, surname, otch) " +
                                           "VALUES(" + "'" + DateTime.Now.ToShortDateString() + "'" + ", " + "'" + textName.Text.ToString() + "'" + ", " + "'" + textSurname.Text.ToString() + "'" + ", " + "'" + textOtch.Text.ToString() + "'" + ")", conMy);
            adapter.Fill(ds);
            ds.Tables.Clear();
            con.CloseConnection();
            Spisok spisok = new Spisok();

            spisok.UpdateTable();
        }
Exemplo n.º 3
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     try
     {
         con = new BDConnection("Students", "127.0.0.1", "3306", "root", "");
         con.OpenConnection();
         conMy   = con.returnCell();
         ds      = new DataSet();
         adapter = new MySqlDataAdapter("DELETE FROM students WHERE idStudents=" + textNumberDel.Text.ToString(), conMy);
         adapter.Fill(ds);
         ds.Tables.Clear();
         con.CloseConnection();
         UpdateTable();
         textNumberDel.Text = "";
     }
     catch
     {
         MessageBox.Show("Введите номер строки, которую необходимо удалить!", "Ошибка!");
     }
 }