delphi 中的sql语句问题

mnlisa 2003-09-17 03:10:54
查询语句如下: select distinct type from store where name = "five"
在tquery控件的sql语句中随便我我怎么写,都出现这个错误:
“参数不足,期待是1”

我的写法有:sql.Text:='select distinct type from store where name ="five";'; 或者是
sql.Add('select distinct type ');
sql.Add('from store ') ;
sql.add('where name = "five"');

为什么“ where name ="five";”这句有问题呢?
那该怎么写那?
...全文
50 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
mnlisa 2003-09-17
  • 打赏
  • 举报
回复
sql server里面是怎么样的,我现在没有试,可能是像hongqing162说的那样吧,
dickeybird888 2003-09-17
  • 打赏
  • 举报
回复
five旁边要用两个单引号而不要用双引号,应该如下:
sql.Add('select distinct type from store where name = ''five''');
CloneCenter 2003-09-17
  • 打赏
  • 举报
回复
将你的 SQL 语句放到 Access 中去执行一下,看看 Access 给你提示的是什么。
Ngg 2003-09-17
  • 打赏
  • 举报
回复
可能這樣子寫吧~~

Sql Add ('select distinct type from store where name ='+''''+five+'''');

這是加在 Tquery 控件語句里的﹗
suton 2003-09-17
  • 打赏
  • 举报
回复
應該是

sql.Text:='select distinct type from store where name =''five''';

吧。
好象ACCESS裡面,字符串也是用單引號的哦。
hongqi162 2003-09-17
  • 打赏
  • 举报
回复
在delphi中必须用''five''

不能用""跟数据库没有关系!
mnlisa 2003-09-17
  • 打赏
  • 举报
回复
恩,谢谢你的提醒,
把你的答案反回来就对了,
access是sql.add('where name = ''five''');
mnlisa 2003-09-17
  • 打赏
  • 举报
回复
to year2000bug:
我用的就是access啊,
你的写法不是和我的一样的吗?
不行啊,那样些就出现那个错误,
year2000bug 2003-09-17
  • 打赏
  • 举报
回复
ms sql2000写法:
sql.Add('select distinct type ');
sql.Add('from store ') ;
sql.add('where name = ''five''');
access写法:
sql.Add('select distinct type ');
sql.Add('from store ') ;
sql.add('where name = "five"');
year2000bug 2003-09-17
  • 打赏
  • 举报
回复
ms sql2000的写法:
sql.Text:='select distinct type from store where name =''five'';';
access的写法:
sql.Text:='select distinct type from store where name ="five";';

2,507

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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