使用execute出现错误!紧急求助!!

blueflag 2006-09-25 05:06:47
我有如下代码段,使用在DLL中 ,编译没有问题,在运行的时候,出现: 查询语法错误,查询子句不完整! 的错误!!

SQLstmt:='insert into "stainfo"'+
'(stano,sname,sex)'+
'VALUES (:InpStano,:InpSname,:InpSex)' ;

FConn.Execute(SQLstmt);

InpStano,InpSname,InpSex 均为变量!!

我代码的作用是: 从stringgrid中取数据存入access数据库! SQL语句就用了一个INSERT ,没有其他的!!
请给予支持,谢谢
...全文
199 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wudi_1982 2006-09-26
  • 打赏
  • 举报
回复
设置一个断点,看看你的SQLstmt究竟是什么
blueflag 2006-09-26
  • 打赏
  • 举报
回复
还未解决,继续UP~~
blueflag 2006-09-26
  • 打赏
  • 举报
回复
找到问题:

我查看了一下 InpStano InpSname InpSex 的值,发现竟然为空!!
我的这几个变量,是从 stringgrid 控件里读的数据!!
with StrGrInport do
for i:=1 to StrGrInport.RowCount do
begin
InpStano:=strgrinport.Cells[1,i];
InpSname:=StrGrInport.Cells[2,i];
InpSex:=StrGrInport.Cells[3,i];

而stringgrid控件里的数据,是读取EXCEL里的数据,而且,已经正确读入! 这问题出在那里???
blueflag 2006-09-26
  • 打赏
  • 举报
回复
TO : wudi_1982

设置了断点,查看了以下,SQLstmt的内容如下:

insert into "stainfo"(stano,sname,sex)VALUES (:InpStano,:InpSname,:InpSex)

有没有什么问题????
blueflag 2006-09-26
  • 打赏
  • 举报
回复
谢谢各位!!
经过这两天的翻山越岭的查资料,终于发现,这个错误的最终的原因竟然是 access 本身的问题,在access中insert into 是由来已久的出错大王!! 我上述的代码中表的关键字全部加上[]成功通过检测!! 郁闷死了,小小的一个[]害我耽误两天工作!!!
solomon19 2006-09-26
  • 打赏
  • 举报
回复
设置了断点,查看了以下,SQLstmt的内容如下:

insert into "stainfo"(stano,sname,sex)VALUES (:InpStano,:InpSname,:InpSex)

有没有什么问题????


LZ这里头values前面少了个空格喔,呵呵
hbqc_zh 2006-09-26
  • 打赏
  • 举报
回复
设个点,跟一下SQLstmt的值,然后在查询分析器中执行一下就知道哪里错了
blueflag 2006-09-25
  • 打赏
  • 举报
回复
再顶~~ 急啊速度啊
blueflag 2006-09-25
  • 打赏
  • 举报
回复
Up@!!@@@@!!!!!
blueflag 2006-09-25
  • 打赏
  • 举报
回复
TO: 先来
改过后,出现 INSERT INTO 语法错误!!
WangZWang 2006-09-25
  • 打赏
  • 举报
回复
//改为如下,还有变量要进行赋值
SQLstmt:='insert into stainfo '+
'(stano,sname,sex) '+
' VALUES (:InpStano,:InpSname,:InpSex)' ;

2,497

社区成员

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

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