2
Follows the code:
//informações necessarias para inserir no DB.
coo := copy(lTemp,53,6);
ccf := copy(lTemp,47,6);
ecf := copy(lTemp,4,20);
//Data sendo formatada para ser inserida
dtc1:= StrToDate(copy(lTemp,65,2)+'/'+copy(lTemp,63,2)+'/'+copy(
lTemp,59,4));
//Query para inserção de linha no DB.
DModuleGrid.ZQuery2.Close;
DModuleGrid.ZQuery2.SQL.Clear;
DModuleGrid.ZQuery2.SQL.Add('INSERT INTO tabc460(dtcompra, impcaixa, numcupom, ccf, valor) VALUES ( "'+DateTimeToStr(dtc1)+'", "'+ecf+'", "'+coo+'", "'+ccf+'", "'+FloatToStr(valortxt)+'")');
DModuleGrid.ZQuery2.ExecSQL;
DModuleGrid.ZQuery2.Close;
DModuleGrid.ZQuery2.SQL.Clear;
DModuleGrid.ZQuery2.SQL.Add('SELECT * FROM tabc460 ORDER BY dtcompra LIMIT 0,'+valor);
DModuleGrid.ZQuery2.Open;
Well, what I need is just to get the date format right, because when you format it like this above, it looks really good on Show Message, the two formats are ok dd/mm/yyyy
, but when I go to see in the database it appears all scrambled 20/03/2023
rather than 17/03/2014
.
What could be wrong?
is returning a syntax error. As if the query is not working.
– Ramon Ruan
What? syntax error is relative to the parameters? if it is, depending on your driver or access component, add a character
p
before each parameter in both Sqlcommand and when filling in the parameters– Caputo