Hallo zusammen,
ich habe von
MSSQL auf die SQLite
DB umgestellt, jedoch funktionieren jetzt einige select-Anweisungen nicht, die aber bereite in
MSSQL funktionierten. Woran kann das liegen?
Delphi-Quellcode:
procedure TfrmGettingStarted.BitBtn5Click(Sender: TObject);
var
Column: TListColumn;
Item: TListItem;
i:Integer;
begin
if not main.dbMain.Connected then
Exit;
main.qryproducts.FetchOptions.AutoClose := False;
main.qryproducts.SQL.Clear;
for i := 1 to Length(edit12.text) do
if not (edit12.text[i] in ['0'..'9'])
then begin
main.qryproducts.SQL.Add(' and fam_db.name like ');
main.qryproducts.SQL.Add(QuotedStr(#37+edit12.text+#37));
main.qryproducts.SQL.Add(' and fam_db.menge like ');
main.qryproducts.SQL.Add(QuotedStr(#37+edit13.text+#37));
//einheit
main.qryproducts.SQL.Add(' and fam_db.einheit_kurz like ');
main.qryproducts.SQL.Add(QuotedStr(#37+edit14.text+#37));
//dafo
main.qryproducts.SQL.Add(' and fam_db.dafo_kurz like ');
main.qryproducts.SQL.Add(QuotedStr(#37+edit15.text+#37));
//hersteller
main.qryproducts.SQL.Add(' and fam_db.hersteller_lang like ');
main.qryproducts.SQL.Add(QuotedStr(#37+edit16.text+#37));
main.qryproducts.SQL.Add('order by fam_db.name asc, fam_db.menge asc');
main.qryproducts.SQL.Add('ORDER_BY fam_db.name, (cast(menge as integer)) ASC');
main.qryproducts.Open;
// main.qryproducts.ExecSQL;
end
else begin //pzn
main.qryproducts.SQL.Add('SELECT *');
main.qryproducts.SQL.Add('FROM fam_db') ;
main.qryproducts.SQL.Add(' WHERE fam_db.nr_pzn like ') ;
main.qryproducts.SQL.Add(QuotedStr(#37+edit12.text+#37));
main.qryproducts.Open;
end;
listview2.Items.Clear;
while not main.qryproducts.Eof do
begin
saveitemdata( main.qryproducts.fieldbyname('nr_pzn').asString, main.qryproducts.fieldbyname('name').asString, main.qryproducts.fieldbyname('menge').asString, main.qryproducts.fieldbyname('einheit_kurz').asString, main.qryproducts.fieldbyname('dafo_kurz').asString, main.qryproducts.fieldbyname('hersteller_lang').asString ,main.qryproducts.fieldbyname('n_bez').asString ,main.qryproducts.fieldbyname('bestand').asString, main.qryproducts.fieldbyname('listen_vk').asString );
main.qryproducts.Next;
end;
end;
[FireDAC][Phys][SQLite] ERROR: near "and": syntax error
FireDAC Executor Error
The application performed an incorrect operation with the database.
-------------------------------------------
Message text: near "and": syntax error
Error code: 00001
Error kind: Other
Server object:
Command text offset: 2
-------------------------------------------
Command text: and fam_db.name like
'%aspirin%'
and fam_db.menge like
'%%'
and fam_db.einheit_kurz like
'%%'
and fam_db.dafo_kurz like
'%%'
and fam_db.hersteller_lang like
'%%'
order by fam_db.name asc, fam_db.menge asc
ORDER_BY fam_db.name, (cast(menge as integer)) ASC
Command parameters:
-------------------------------------------
Exception class name: ESQLiteNativeException
FireDAC error code: 1600
FireDAC object name: main.qryProducts