功能:两个TextB控件,一个用于输入需要查找的数据列名,另一个用于待查找的具体数据
查询结果通过MessageBox显示出来
1. 查找功能的实现
public bool DataSelect(TextBox TextBox1, TextBox TextBox2, TextBox TextBox3, DataGridView dataGridView1, OleDbConnection conn)
{
string strSelect = TextBox1.Text;
string strSearch = TextBox2.Text;
if (strSearch == "" || strSearch == null)
{
MessageBox.Show("请输入查询内容!", "提示");
return false;
}
else
{
string sqlSelect = "select * from Student where [" + @strSelect + "] = '" + @strSearch + "'";
OleDbCommand cmd = new OleDbCommand(sqlSelect, conn);
try
{
conn.Open();