查询表达式错误 [英] extra in query expression error
问题描述
OleDbCommand cmd = new OleDbCommand("select * from patientdetail where refby=@refby AND datep BETWEEN @date1 AND @date2)", con);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
cmd.Parameters.Add(new OleDbParameter("@date1", dateTimePickerstart.Value.ToShortDateString()));
cmd.Parameters.Add(new OleDbParameter("@date2", dateTimePickerend.Value.ToShortDateString()));
cmd.Parameters.Add(new OleDbParameter("@refby", cmbboxdocname.Text));
我正在尝试执行此代码..但是此代码给我查询表达式"refby = @ refby AND datep @ date1 AND @ date2)之间的错误"Extra)".
"refby"是病人详细信息"表中的医生名称.我想搜索医生姓名(refby)匹配的日期之间的所有记录.
请给我适当的搜索解决方案.
对不起,我的英语不好,希望您能理解我的意思.
在此先谢谢您.
I am trying to execute this code.. but this code give me error "Extra ) in query expression ''refby=@refby AND datep BETWEEN @date1 AND @date2)''."
''refby'' is a doctor name in ''patientdetail'' table. i want to search all records between date where doctor name (refby) match.
Please give me a proper solution for searching.
Sorry for my bad english Hope you understand what i am saying.
Thanks in advance.
推荐答案
错误消息很简单.您的查询在末尾有一个额外的).
这应该是正确的.
The error message is straight forward. Your query has an extra ) towards the end.
This should be correct.
OleDbCommand cmd = new OleDbCommand("select * from patientdetail where refby=@refby AND datep BETWEEN @date1 AND @date2", con);
尝试删除)"形式:
Try to remove ")" form:
OleDbCommand cmd = new OleDbCommand("select * from patientdetail where refby=@refby AND datep BETWEEN @date1 AND @date2)", con);
看起来像这样:
to look like this:
OleDbCommand cmd = new OleDbCommand("select * from patientdetail where refby=@refby AND datep BETWEEN @date1 AND @date2", con);
您的代码:
Your code:
OleDbCommand cmd = new OleDbCommand("select * from patientdetail where refby=@refby AND datep BETWEEN @date1 AND @date2)", con);
您似乎在选择的末尾添加了一个额外的'')''.删除它,它应该可以工作.
试试:
You seem to have added an extra '')'' at the end of you selection. Remove it and it should work.
Try:
OleDbCommand cmd = new OleDbCommand("select * from patientdetail where refby=@refby AND datep BETWEEN @date1 AND @date2", con);
这篇关于查询表达式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!