I'm trying to add some data in an access database. But I'm having trouble because this returning the error:
ADOQuery1 missing sql property
Realized several modifications to the code and so far nothing has worked .
What am I doing wrong ?
try
ADOConnection1.Connected := true;
ADOQuery1.Active := true;
try
///
AdoQuery1.SQL.Clear;
ADOQuery1.SQL.Add('INSERT INTO IP (tit_ip, url_ip, im_ip, des_ip) VALUES ( :a, :b, :c, :d )');
AdoQuery1.parameters.parambyname('a').value := 'sd';
AdoQuery1.parameters.parambyname('b').value := 'sdsd';
AdoQuery1.parameters.parambyname('c').value := 'sd';
AdoQuery1.parameters.parambyname('d').value := 'df';
AdoQuery1.ExecSQL;
AdoQuery1.close;
finally
ADOQuery1.Active := false;
ADOConnection1.Connected := false;
end;
except
showmessage('Erro');
end;
The debugger should have shown you the line that failed. Remove
That is the same as opening a query, but you do that before you set the SQL. If you do insert, delete or update you should really use a
TADOCommand
instead of aTADOQuery
, but aTADOQuery
will work.