调用此查询时,我在运行时期间遇到语法错误。
adoquery1.Active := false;
adoquery1.SQL.Clear;
SQLQuery := 'INSERT INTO Comics ';
SQLQuery := SQLQuery + '(Name,Issue,Series,Volume,Poster,';
SQLQuery := SQLQuery + 'Desc,Writer,Artist,Read,Link,Extra) ';
SQLQuery := SQLQuery + 'VALUE('+ quotedstr(SeriesName+' '+IssueNumber);
SQLQuery := SQLQuery + ','+ quotedstr(IssueNumber);
SQLQuery := SQLQuery + ','+ quotedstr(SeriesName);
SQLQuery := SQLQuery + ','+ quotedstr(VolumeNumber);
SQLQuery := SQLQuery + ','+ quotedstr(Poster);
SQLQuery := SQLQuery + ','+ quotedstr(Desc);
SQLQuery := SQLQuery + ','+ quotedstr(Writer);
SQLQuery := SQLQuery + ','+ quotedstr(Artist);
SQLQuery := SQLQuery + ','+ quotedstr(haveRead);
SQLQuery := SQLQuery + ','+ quotedstr(filelink);
SQLQuery := SQLQuery + ','+ quotedstr(Extra);
SQLQuery := SQLQuery + ')';
memo1.Text := SQLQuery;
adoquery1.SQL.Add(SQLQuery);
adoquery1.Active := true;
当我执行memo1.text = sqlquery时,它看起来没问题,有什么建议吗? 这是我在memo1.text中得到的。
INSERT INTO Comics (Name,Issue,Series,Volume,Poster,Desc,Writer,Artist,Read,Link,Extra VALUE('xmen 8','8','xmen','1','na','Some Description','BOBwriter','BOBArtist','Yes','C:\Comics\xmen8.cbr','Some Extra info')
答案 0 :(得分:5)
Desc
是保留字,因此您应该使用[Desc]
或将其括在反引号中(我不知道您正在使用哪个数据库)。
更多:我认为它应该是VALUES(
而不是VALUE(
。
INSERT INTO Comics
(Name, Issue, Series, Volume, Poster, [Desc],
Writer, Artist, [Read], Link, Extra)
VALUES
('xmen 8', '8', 'xmen', '1', 'na', 'Some Description',
'BOBwriter', 'BOBArtist', 'Yes', 'C:\Comics\xmen8.cbr','Some Extra info')
答案 1 :(得分:3)
将{strong> Reserved Word DESC
与brackets
adoquery1.Active := false;
adoquery1.SQL.Clear;
SQLQuery := 'INSERT INTO Comics ';
SQLQuery := SQLQuery + '(Name,Issue,Series,Volume,Poster,';
SQLQuery := SQLQuery + '[Desc],Writer,Artist,[Read],Link,Extra) ';
SQLQuery := SQLQuery + 'VALUES ('+ quotedstr(SeriesName+' '+IssueNumber);
SQLQuery := SQLQuery + ','+ quotedstr(IssueNumber);
SQLQuery := SQLQuery + ','+ quotedstr(SeriesName);
SQLQuery := SQLQuery + ','+ quotedstr(VolumeNumber);
SQLQuery := SQLQuery + ','+ quotedstr(Poster);
SQLQuery := SQLQuery + ','+ quotedstr(Desc);
SQLQuery := SQLQuery + ','+ quotedstr(Writer);
SQLQuery := SQLQuery + ','+ quotedstr(Artist);
SQLQuery := SQLQuery + ','+ quotedstr(haveRead);
SQLQuery := SQLQuery + ','+ quotedstr(filelink);
SQLQuery := SQLQuery + ','+ quotedstr(Extra);
SQLQuery := SQLQuery + ')';
memo1.Text := SQLQuery;
adoquery1.SQL.Add(SQLQuery);
adoquery1.Active := true;
答案 2 :(得分:2)
使用Values
代替value
Desc和Read是保留的关键字,因此请将其括在方括号中
您忘记在Values
关键字之前保留右括号。
INSERT INTO Comics
(Name,
Issue,
Series,
Volume,
Poster,
[Desc],
Writer,
Artist,
[Read],
Link,
Extra)
VALUES ('xmen 8',
'8',
'xmen',
'1',
'na',
'Some Description',
'BOBwriter',
'BOBArtist',
'Yes',
'C:\Comics\xmen8.cbr',
'Some Extra info')