I have this code
try
ADOconnection1.connected:=true;
ADOconnection1.Execute(memo1.Lines.text);
if AdoConnection1.Connected then AdoConnection1.Close;
ShowMessage('Floorplan imported to DB');
except
ShowMessage('DB error');
end;
Works fine but exception handling is not sufficient.
DB error message shows query has syntax error. But how to handle exception like this?
Msg 2628, Level 16, State 1, Line 2
String or binary data would be truncated in table 'sites.dbo.sites_plans', column 'building'.
Truncated value: 'ISI_Head'.
The statement has been terminated.
Nothing is inserted and SQL Server throws error if I run the query manually in SQL Server Management Studio, but my application shows 'Floorplan imported to DB' and this is wrong. Because nothing is really inserted.
Is possible get some return value from
ADOconnection1.Execute(memo1.Lines.text);
how many rows have been inserted? Or some return code to handle error?
Thanks for any help