如何在C#Windows窗体应用程序中搜索Microsoft Access记录?
代码:
private void btnsearch_Click(object sender, EventArgs e)
{
dataAdapter = new OleDbDataAdapter("SELECT * from tblStudents WHERE studid='" +
txtstudid.Text + "' ",
conn);
dataset = new DataSet();
dataAdapter.Fill(dataset);
dataGridView1.DataSource = dataset.Tables[0];
}
答案 0 :(得分:0)
//BindingSource to sync DataTable and DataGridView
BindingSource bSource = new BindingSource();
//set the BindingSource DataSource
bSource.DataSource = ds.Tables[0];
//set the DataGridView DataSource
dataGridView1.DataSource = bSource;
要将更改恢复到数据库,您只需调用Update()
的{{1}}并使用OleDbDataAdapter
作为参数来完成此操作。
DataTable