简体   繁体   English

名为“ Language”的SQL表字段给出SQL错误-Delphi

[英]SQL table field named “Language” giving SQL error - delphi

I am building a application for school that displays and adds entries to tables in a neat and user friendly way. 我正在为学校构建一个应用程序,以一种简洁,用户友好的方式显示条目并将其添加到表中。 Whilst programming the "adding of new records" part, I came across this error 在对“添加新记录”部分进行编程时,我遇到了此错误

Syntax error in INSERT INTO statement

I tried fixing it by manually going through the list of fields I am entering and found that only one gave an error even though this field is exactly the same to all the other fields. 我尝试通过手动检查要输入的字段列表来修复它,发现即使该字段与所有其他字段完全相同,也只有一个错误。 If I purposefully spell the field wrong I get another error. 如果我故意将字段拼写错误,则会出现另一个错误。 My Code looks like this: 我的代码如下所示:

with dmInfo do
begin
  qryInfo.SQL.Clear;
  qryInfo.SQL.Add('INSERT INTO tblGymnast');
  qryInfo.SQL.Add('(GymnastID, Surname, Name, NickName, FamilyID, PosCode, CellNo, SAGFID, Photo, StartDate, BirthDate, Gender, Race, Category, IDNum, UpgrdTo, SchoolID, LevelID, TransID, DokterID, MedNum, MedID, Language)');

  qryInfo.SQL.Add(' VALUES(:GymnastID, :Surname, :Name, :NickName, :FamilyID, :PosCode, :CellNo, :SAGFID, :Photo, :StartDate, :BirthDate, :Gender, :Race, :Category, :IDNum, :UpgrdTo, :SchoolID, :LevelID, :TransID, :DokterID, :MedNum, :MedID, :Language)');

      qryInfo.Parameters.ParamByName('GymnastID').Value:= 'a';
      qryInfo.Parameters.ParamByName('Surname').Value:= 'a';
      qryInfo.Parameters.ParamByName('Name').Value:= 'a';
      qryInfo.Parameters.ParamByName('NickName').Value:= 'a';
      qryInfo.Parameters.ParamByName('FamilyID').Value:= 'a';
      qryInfo.Parameters.ParamByName('PosCode').Value:= 'a';
      qryInfo.Parameters.ParamByName('CellNo').Value:= 'a';
      qryInfo.Parameters.ParamByName('SAGFID').Value:= 'a';
      qryInfo.Parameters.ParamByName('Photo').Value:= 'a';
      qryInfo.Parameters.ParamByName('StartDate').Value:= 'a';
      qryInfo.Parameters.ParamByName('BirthDate').Value:= 'a';
      qryInfo.Parameters.ParamByName('Gender').Value:= 'a';
      qryInfo.Parameters.ParamByName('Language').Value:= 'a'; //This gives the error
      qryInfo.Parameters.ParamByName('Race').Value:= 'a';
      qryInfo.Parameters.ParamByName('Category').Value:= 'a';
      qryInfo.Parameters.ParamByName('IDNum').Value:= 'a';
      qryInfo.Parameters.ParamByName('UpgrdTo').Value:= 'a';
      qryInfo.Parameters.ParamByName('SchoolID').Value:= 'a';
      qryInfo.Parameters.ParamByName('LevelID').Value:= 'a';
      qryInfo.Parameters.ParamByName('TransID').Value:= 'a';
      qryInfo.Parameters.ParamByName('DokterID').Value:= 'a';
      qryInfo.Parameters.ParamByName('MedNum').Value:= 'a';
      qryInfo.Parameters.ParamByName('MedID').Value:= 'a';

  qryInfo.ExecSQL;
end;

Please help as I have been struggling with this for the whole day and haven't gotten anywhere. 请帮忙,因为我整天都在为此而苦苦挣扎,而且一无所获。

Regards 问候

[] or "" signifys to the RDBMs that the word is a column name not a reserved keyword. []或“”向RDBM表示该单词是列名而不是保留关键字。 Language is a reserved keyword in SQL. 语言是SQL中的保留关键字。

for good measure I also changed the parameter name to Lang because you identified the parameter assignment as teh issue location. 出于良好的考虑,我还将参数名称更改为Lang,因为您将参数分配标识为发布位置。

with dmInfo do
begin
  qryInfo.SQL.Clear;
  qryInfo.SQL.Add('INSERT INTO tblGymnast');
  qryInfo.SQL.Add('(GymnastID, Surname, Name, NickName, FamilyID, PosCode, CellNo, SAGFID, Photo, StartDate, BirthDate, Gender, Race, Category, IDNum, UpgrdTo, SchoolID, LevelID, TransID, DokterID, MedNum, MedID, [Language])');

  qryInfo.SQL.Add(' VALUES(:GymnastID, :Surname, :Name, :NickName, :FamilyID, :PosCode, :CellNo, :SAGFID, :Photo, :StartDate, :BirthDate, :Gender, :Race, :Category, :IDNum, :UpgrdTo, :SchoolID, :LevelID, :TransID, :DokterID, :MedNum, :MedID, :Lang)');

      qryInfo.Parameters.ParamByName('GymnastID').Value:= 'a';
      qryInfo.Parameters.ParamByName('Surname').Value:= 'a';
      qryInfo.Parameters.ParamByName('Name').Value:= 'a';
      qryInfo.Parameters.ParamByName('NickName').Value:= 'a';
      qryInfo.Parameters.ParamByName('FamilyID').Value:= 'a';
      qryInfo.Parameters.ParamByName('PosCode').Value:= 'a';
      qryInfo.Parameters.ParamByName('CellNo').Value:= 'a';
      qryInfo.Parameters.ParamByName('SAGFID').Value:= 'a';
      qryInfo.Parameters.ParamByName('Photo').Value:= 'a';
      qryInfo.Parameters.ParamByName('StartDate').Value:= 'a';
      qryInfo.Parameters.ParamByName('BirthDate').Value:= 'a';
      qryInfo.Parameters.ParamByName('Gender').Value:= 'a';
      qryInfo.Parameters.ParamByName('Lang').Value:= 'a'; //This gives the error
      qryInfo.Parameters.ParamByName('Race').Value:= 'a';
      qryInfo.Parameters.ParamByName('Category').Value:= 'a';
      qryInfo.Parameters.ParamByName('IDNum').Value:= 'a';
      qryInfo.Parameters.ParamByName('UpgrdTo').Value:= 'a';
      qryInfo.Parameters.ParamByName('SchoolID').Value:= 'a';
      qryInfo.Parameters.ParamByName('LevelID').Value:= 'a';
      qryInfo.Parameters.ParamByName('TransID').Value:= 'a';
      qryInfo.Parameters.ParamByName('DokterID').Value:= 'a';
      qryInfo.Parameters.ParamByName('MedNum').Value:= 'a';
      qryInfo.Parameters.ParamByName('MedID').Value:= 'a';

  qryInfo.ExecSQL;
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM