0
我試圖插入新記錄到使用SQL我的數據庫,但它總是告訴我,我有一個語法錯誤在FROM子句。語法錯誤在SQL SELECT INTO FROM德爾福
我看不出錯誤。
下面是代碼:
procedure TForm1.BitBtn7Click(Sender: TObject);
var
sCategoryName :string;
begin
sCategoryName := InputBox('Category Name', 'Please enter your category name that you would like to add','');
with dmRecords do
begin
qryRecords.Active := False;
qryRecords.SQL.Add('INSERT INTO [Category of Income]([Category Name])');
qryRecords.SQL.Add('VALUES ' + '(' + QuotedStr(sCategoryName) + ')');
qryRecords.ExecSQL;
qryRecords.SQL.Add('SELECT * FROM [Category of Income] ORDER BY [Category ID]');
qryRecords.Active := True;
end;
end;
一點題外話,請停止使用並置的SQL語句,使用參數來代替。你很容易[SQL注入](https://en.wikipedia.org/wiki/SQL_injection) – whosrdaddy