function TDBModule.AddNewDatabaseItem (DBName:
String; DatabaseData: TDatabaseData;
var TreeNodeData: PTreeMenuEntry): Integer;
begin
Result := 0;
with AdsQuery,
SQL do
try
Clear;
Add ('
INSERT INTO "' + DBName + '
DB" ' +
'
(CategoryID, ' +
'
Problem, ' +
'
ProblemDescription, ' +
'
Solution, ' +
'
SolutionDescription, ' +
'
SymbolType1, ' +
'
Symbol1, ' +
'
SymbolType2, ' +
'
Symbol2) ' +
'
VALUES (' +
#39 + DelphiEscapeString (DatabaseData.CategoryID) + #39 + '
, ' +
'
:Problem, ' +
'
:ProblemDescription, ' +
'
:Solution, ' +
'
:SolutionDescription, ' +
inttostr (Integer (DatabaseData.SymbolType1)) + '
, ' +
'
:Symbol1, ' +
inttostr (Integer (DatabaseData.SymbolType2)) + '
, ' +
'
:Symbol2);');
Prepare;
ParamByName ('
Problem').AsMemo := DatabaseData.Problem;
ParamByName ('
ProblemDescription').AsMemo := DatabaseData.ProblemDescription;
ParamByName ('
Solution').AsMemo := DatabaseData.Solution;
ParamByName ('
SolutionDescription').AsMemo := DatabaseData.SolutionDescription;
if (DatabaseData.SymbolType1 <> stNoSymbol)
then
begin
DatabaseData.Symbol1.Position := 0;
ParamByName ('
Symbol1').LoadFromStream (DatabaseData.Symbol1, ftBlob);
end
else ParamByName ('
Symbol1').Clear;
if (DatabaseData.SymbolType2 <> stNoSymbol)
then
begin
DatabaseData.Symbol2.Position := 0;
ParamByName ('
Symbol2').LoadFromStream (DatabaseData.Symbol2, ftBlob);
end
else ParamByName ('
Symbol2').Clear;
ExecSQL;
Result := LastAutoIncVal;
Close;
inc (TreeNodeData.ItemsCount);
except
ThrowSQLException (
SQL[0]);
end;
end;