关于sql的查询问题,请大家帮忙!

s_delhpi 2002-05-09 09:22:05
riqi1:=ComboBox2.Text+'-'+ComboBox3.Text+'-'+ComboBox4.Text;
riqi2:=ComboBox2.Text+'-'+ComboBox5.Text+'-'+ComboBox6.Text;
fstr:='select * from 销售库 where (日期>=#%s#) and (日期<=#%s#)';
这个是我在用access的时候的代码,没问题,现在我把数据库改为sql时,就出错了,“#”报错,请问应该怎么改呢?
...全文
50 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
hycao 2002-05-09
  • 打赏
  • 举报
回复
riqi1:='2001-1-1';
riqi2:='2001-3-3';
fstr:='select * from 销售库 where (日期>='''+riqi1+''') and (日期<='''+riqi2+''')';

s_delhpi 2002-05-09
  • 打赏
  • 举报
回复
还是不对啊:(请你写的具体一点好吗?
riqi1:='2001-1-1';
riqi2:='2001-3-3'

fstr:='select * from 销售库 where (日期>=''riqi1'') and (日期<=''riqi2'')';
这样对吗?
ihihonline 2002-05-09
  • 打赏
  • 举报
回复
你说的那个问题是access的字符表现形式,用在sql server中,你用'''就可以了
s_delhpi 2002-05-09
  • 打赏
  • 举报
回复
出错了,报错“2001-1-1”无效
zswangII 2002-05-09
  • 打赏
  • 举报
回复
fstr:='select * from 销售库 where (日期>=''%s'') and (日期<=''%s'')';
huojiehai 2002-05-09
  • 打赏
  • 举报
回复
riqi1:=ComboBox2.Text+'-'+ComboBox3.Text+'-'+ComboBox4.Text;
riqi2:=ComboBox2.Text+'-'+ComboBox5.Text+'-'+ComboBox6.Text;
fstr:='select * from 销售库 where 日期>='+strtodatetime(riqi1)+' and 日期<='+strtodatetime(riqi2);

5,388

社区成员

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

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