try
{
string myconn=
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:/zzz.mdb");
OleDbConnection thisconnection = new OleDbConnection(myconn);
OleDbDataAdapter thisadapter = new OleDbDataAdapter("select * from 表名", thisconnection);
string cx = "select * from 表名 where 1=1";
if (textBoxfwbh.Text != "")
{
cx += "and 终点站='" + listBox1.Text + "'";
}
thisadapter. = cx;
thisadapter.SelectCommand.Connection = thisconnection;
DataSet thisdataset = new DataSet();
thisconnection.Open();
thisadapter.SelectCommand.ExecuteNonQuery();
thisadapter.Fill(thisdataset, "表名");
dataGridView1.DataSource = thisdataset.Tables["表名"];
}
catch (Exception error)
{
MessageBox.Show("查询数据失败:" + error.Message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
用上面的试试看~~