Các bác xem dùm mình trong phần button1_click (Mình đánh chữ đỏ)...Khi mình thay đổi tên bảng khác cho bảng Lop trong câu lệnh: string strSQL = "select * from Lop"; thì nó vẫn cứ hiển thị mỗi bảng Lop ??? Các bác cùng trong 1 datbase nhá các bác...Thậm chí trong hàm: private void button1_Click(object sender, EventArgs e) mình ko làm j, khi chạy bấn button1 nó vẫn hiển ra kết quả bảng Lop ???
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Data_SQL
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//================================================== ==========================//

private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}

//================================================== =======//
public SqlConnection sqlConn;
public SqlDataReader rdr;

public void KetNoi()
{
try
{
//conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=D:\\atu.mdb");

sqlConn = new SqlConnection();

string strconn = "Server=ATU-PC\\SQLEXPRESS; DataBase=QLSV; User ID =sa ; Password =tieutuht ";
sqlConn.ConnectionString = strconn;
//conn.Open();
Console.WriteLine("Ket noi thanh cong");
//Console.ReadLine();

}
catch (Exception ex)
{
Console.WriteLine("Loi ket noi" + ex);
}
}
public void NgatKetNoi()
{
sqlConn.Close();
}

private void button1_Click(object sender, EventArgs e)
{
KetNoi();
try
{
sqlConn.Open();
}
catch
{
MessageBox.Show("Chưa kết nối DataBase");
}
string strSQL = "select * from Lop";
LoadDataInToDataGrid(strSQL, sqlConn, dataGridView1);
NgatKetNoi();
}
//================================================== =======//
private void LoadDataInToDataGrid(string str, SqlConnection sqlCNN, DataGridView dgrid)
{
SqlDataAdapter sqlADP = new SqlDataAdapter(str, sqlCNN);
DataTable dttable = new DataTable();
sqlADP.Fill(dttable);
dttable.DefaultView.AllowEdit = true;
dttable.DefaultView.AllowDelete = true;
dttable.DefaultView.AllowNew = true;
dgrid.DataSource = dttable;
}

private void button3_Click(object sender, EventArgs e)
{
string value = textBox1.Text;
KetNoi();
sqlConn.Open();
string sql = "insert into Lop values('" + value + "')";
SqlCommand lenh = new SqlCommand(sql, sqlConn);
int i = lenh.ExecuteNonQuery();
if (i != 0) MessageBox.Show("Insert Success !!!");
else MessageBox.Show("Insert unsuccess !!!");
NgatKetNoi();
}

private void button4_Click(object sender, EventArgs e)
{
string value1 = textBox2.Text;
string value2 = textBox3.Text;
KetNoi();
sqlConn.Open();
string sql = "update Lop set Lop.TenLop='" + value2 + "' where Lop.TenLop='" + value1 + "'";
SqlCommand lenh = new SqlCommand(sql, sqlConn);
int i = lenh.ExecuteNonQuery();
if (i != 0) MessageBox.Show("Update Success !!!");
else MessageBox.Show("Update unsuccess !!!");
NgatKetNoi();
}

private void button5_Click(object sender, EventArgs e)
{
string id = textBox4.Text;
string lop = textBox5.Text;
KetNoi();
sqlConn.Open();
string sql = "Select * from Lop where Lop.TenLop='" + lop + "' or Lop.MaLop="+id;
LoadDataInToDataGrid(sql, sqlConn, dataGridView1);
NgatKetNoi();
}

private void button6_Click(object sender, EventArgs e)
{
string id = textBox4.Text;
string lop = textBox5.Text;
KetNoi();
sqlConn.Open();
string sql = "delete from Lop where Lop.TenLop='" + lop + "' or Lop.MaLop=" + id;
SqlCommand lenh = new SqlCommand(sql, sqlConn);
int i = lenh.ExecuteNonQuery();
if (i != 0) MessageBox.Show("Delete Success !!!");
else MessageBox.Show("Delete Unsuccess !!!");
NgatKetNoi();
}


}
}