查询表达式中缺少(运算符)

时间:2013-01-27 17:59:04

标签: c# ms-access

Lid是ms访问中的自动编号字段。 错误消息:查询表达式'Lid ='

中缺少(运算符)
db.Search_Grid_Add(LoanInfo_dgv, "Select * From Loan_Info Where Lid=" + LoanId_cb.Text + "");

1 个答案:

答案 0 :(得分:3)

也许LoanId_cb.Text不被解析为int? 尝试:

int lid;
string lidText = LoanId_cb.Text.Trim();
if(int.TryParse(lidText , out lid))
{
    db.Search_Grid_Add(LoanInfo_dgv, "Select * From Loan_Info Where Lid="+lidText );
}
else
{
   MessageBox.Show(lidText + " can't be parsed as int.");
}