写数据库发生错误,是 什么异常类错误 (100分)

  • 主题发起人 主题发起人 fossil
  • 开始时间 开始时间
F

fossil

Unregistered / Unconfirmed
GUEST, unregistred user!
tyr
ecxcept on ??do
 
CommandText:='select * from portconfg where head='+IntToStr(head30)
 
肯定错,语法问题
var head30:String;
head30:=’30‘

CommandText := 'select * from portconfg where head =‘+head30;

如果你要integer也行

head30:=30

CommandText := 'select * from portconfg where head =‘+inttostr(head30);
 
如果你的head30是Integer类型的话,应该这么写
CommandText := 'select * from portconfg where head = ' + IntToStr(head30);
如果你的head30是Double类型的话,应该这么写
CommandText := 'select * from portconfg where head = ' + FloatToStr(head30);
....................
类型不匹配而已
 
类型是不是一致head跟head30,用下面的,肯定对的,试过N 次 了。
CommandText := 'select * from portconfg where head = ' + '''' + inttostr(head30) + '''';
 
够了,够了
 
我一时失手
 
同意:fshell
如果你的head30是Integer类型的话,应该这么写
CommandText := 'select * from portconfg where head = ' + IntToStr(head30);
如果你的head30是Double类型的话,应该这么写
CommandText := 'select * from portconfg where head = ' + FloatToStr(head30);
....................
类型不匹配而已


其他的都不怎么同意

 
CommandText := 'select * from portconfg where head ='''+inttostr(head30)+''''
或使用Parameter.
 
CommandText := 'select * from portconfg where head =‘+inttostr(head30);
这样就行了!@
 
CommandText := 'select * from portconfg where head ='+inttostr(head30);

给分
 
奇怪,怎么大家的回答和问题都不配套的:)
 
tyr
ecxcept on e:except
do
showmessage(e.message);
end;
 

Similar threads

后退
顶部