老是出错过来帮看看?

panjinfu80 2006-01-16 05:24:47
select a.*,[b.name] as Name from Place a ,Area b where [a.AreaID]=[b.AreaID] and [b.AreaID] ='''+inttostr(NowAreaID)+''' order by a.PlaceID


'''+inttostr(NowAreaID)+''' 是赋值的(SQL语句),老是数据类型不匹配,AreaID整型,NowAreaID也是整型该什么转换如果是字符型又如何转换?
...全文
114 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fangshiguang 2006-01-18
  • 打赏
  • 举报
回复
如果你真的是在Delphi环境中,可以参考如下:
with adoqry do
begin
close;
sql.clear;
sql.add('select a.*,[b.name] as Name from Place a ,Area b where [a.AreaID]=[b.AreaID] and [b.AreaID] ='+inttostr(NowAreaID)+' order by a.PlaceID');
open;
end;

changechange 2006-01-17
  • 打赏
  • 举报
回复
select a.*,[b.name] as Name from Place a ,Area b where [a.AreaID]=[b.AreaID] and [b.AreaID] ='''+inttostr(NowAreaID)+''' order by a.PlaceID

上述语句明显数据类型错误!

'''+inttostr(NowAreaID)+''' 的结果 [b.AreaID] = '某个字符串了',比如[b.AreaID] = '1'
而正确的结果是 [b.AreaID] = 1

所以应该


'select a.*,[b.name] as Name from Place a ,Area b where [a.AreaID]=[b.AreaID] and [b.AreaID] =' + inttostr(NowAreaID) + ' order by a.PlaceID'
wwwwb 2006-01-17
  • 打赏
  • 举报
回复
inttostr()是DELPHI的函数,在ACCESS中,直接用&.
try:
select a.*,[b.name] as Name from Place a ,Area b where [a.AreaID]=[b.AreaID] and [b.AreaID] =''& NowAreaID +'' order by a.PlaceID
panjinfu80 2006-01-16
  • 打赏
  • 举报
回复
ACCESS不像SQL那样可以自动隐性转换数据类型的,有没有什么函数可以转换的?像字符型转换成整型的函数?
panjinfu80 2006-01-16
  • 打赏
  • 举报
回复
ACCESS不像那样可以自动隐性转换数据类型的,有没有什么函数可以转换的?像字符型转换成整型的函数?
samfeng_2003 2006-01-16
  • 打赏
  • 举报
回复
select a.*,[b.name] as Name from Place a ,Area b where [a.AreaID]=[b.AreaID] and [b.AreaID] =''+inttostr(NowAreaID)+'' order by a.PlaceID

这样试一试呢?

7,714

社区成员

发帖
与我相关
我的任务
社区描述
Microsoft Office Access是由微软发布的关系数据库管理系统。它结合了 MicrosoftJet Database Engine 和 图形用户界面两项特点。
社区管理员
  • Access
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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