"未处理的类型' System.Data.OleDb.OleDbException'发生在System.Data.dll
中其他信息:标准表达式中的数据类型不匹配。"
OleDbCommand commandmenu = new OleDbCommand();
commandmenu.Connection = oleConn;
string querymenu = "select * from AllMeals where MOTD = '1'";
commandmenu.CommandText = querymenu;
string menutype = "";
string menuitemname = "";
OleDbDataReader readermenu = commandmenu.ExecuteReader();
while (readermenu.Read())
{
menutype = readermenu.GetString(3);
menuitemname = readermenu.GetString(1);
}
我试图从我的访问数据库中获取字符串,但是我收到此错误,我的查询文本有问题吗? MOTD是AllMeals表中的是/否字段。
答案 0 :(得分:0)
您的查询存在问题。试试这个:
string querymenu = "select * from AllMeals where MOTD ="+ true;
答案 1 :(得分:0)
删除single quotes
string querymenu = "select * from AllMeals where MOTD = 1";