语法错误(操作符丢失)怎么解决?

hhkun0120 2011-08-19 04:51:53
我的代码如下:

adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text := 'select * from BookInfo where BookID= ' + trim(bookIDEdit.text) +
''' or bookname=''' + trim(booknameEdit.Text) + ''' or classes= '
+ trim(TypeEdit.text) + '''';
adoquery1.Open;
if adoquery1.RecordCount = 0 then
begin
Application.MessageBox('no result in database','^_^注意!',MB_OK);
bookIDEdit.Text :='';
typeEdit.Text :='';
end


...全文
196 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hhkun0120 2011-08-19
  • 打赏
  • 举报
回复
[code=Delphi(Pascal)]
adoquery1.SQL.Text := 'select * from BookInfo where BookID='+ trim(bookIDEdit.text) + ' or bookname=''' + trim(booknameEdit.Text) + ''' or classes= '''+ trim(TypeEdit.text) +'''';[/code
这样就行了,BookInfo是整型, 第一个or前面为什么也是单引号呢?
hhkun0120 2011-08-19
  • 打赏
  • 举报
回复

改成那样又显示这个错误了...


这是我作业的截图
hhkun0120 2011-08-19
  • 打赏
  • 举报
回复
最后的四个单引号表示什么?[Quote=引用 3 楼 m617105 的回复:]
少单引号
[/Quote]
浩南_哥 2011-08-19
  • 打赏
  • 举报
回复
少单引号
hhkun0120 2011-08-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 m617105 的回复:]
adoquery1.SQL.Text := 'select * from BookInfo where BookID= ''' + trim(bookIDEdit.text) +
''' or bookname=''' + trim(booknameEdit.Text) + ''' or classes= '''
+ trim(TypeEdit.text) + '''';
[/Quote]为什么这样写呢?与上面我写的代码区别在哪里啊?
浩南_哥 2011-08-19
  • 打赏
  • 举报
回复
adoquery1.SQL.Text := 'select * from BookInfo where BookID= ''' + trim(bookIDEdit.text) +
''' or bookname=''' + trim(booknameEdit.Text) + ''' or classes= '''
+ trim(TypeEdit.text) + '''';

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧