c#数据库查询,并显示
public static void MDBSelect(string Address, string TableName,string Search,string SearchWorth,string Result)
{
OleDbConnection conn;
conn = new OleDbConnection("Provider=Microsoft.Jet.oledb.4.0;Data Source=" + Address + ";Jet Oledb:Engine Type=5");
conn.Open();
OleDbCommand cmd = new OleDbCommand("select * from " + TableName + " where " + Search +" = "+"'SearchWorth'", conn);
cmd.CommandType = CommandType.Text;
OleDbDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
MessageBox.Show("good");
}
conn.Close();
}
如以上自己希望获得Search字段下的SearchWorth值对应的 Result字段值;这段程序运行sdr.read为false,为什么?
同时,怎么把查找到的结果显示以检查结果?求大神帮助!