I am talking about TStoredProc but it seems same problem exist in other components when you are working on iOS or Android application.
This is my code calling a stored procedure:
Code: Select all
procedure TUser.BreakfastCals;
var
ImConnected: Boolean;
begin
ImConnected := DM1.conSQL.Connected;
if not ImConnected then
DM1.conSQL.Open;
try
with DM1.sp_ThisDateLogedbreakfast do
begin
Close;
Prepare;
ParamByName('@CaloryDate').Value := TodayDate;
ParamByName('@UserId').Value := UserId;
ParamByName('@Sum').Value := 0;
Execute;
fBreakfastCals := ParamByName('@Sum').Value;
end;
except on E: Exception do
begin
ShowMessage('Error');
frmStartUp.AppClose;
end;
end;
frmToday.lblBreakfact.Text := IntToStr(fBreakfastCals) + ' kcal';
end;