I'm using Firebird embedded 1.5.2.4731 and I can't seem to use TZStoredProc - I always get an exception in the destructor of the TZConnection if I try to use them. I don't have any problem with TZQuery.
Code is as follows...
[syntax="c"]
std::auto_ptr<TZStoredProc> qryEditRule(new TZStoredProc(NULL));
//std::auto_ptr<TZReadOnlyQuery> qryEditRule(new TZReadOnlyQuery(NULL));
qryEditRule->Connection = frmData->Database;
qryEditRule->StoredProcName = "CHANGE_FTP_RULE_SP";
/*qryEditRule->SQL->Add("UPDATE FTP SET \"NAME\" = :NAME,");
qryEditRule->SQL->Add("\"ENABLED\" = :ENABLED, \"TYPE\" = :TYPE,");
qryEditRule->SQL->Add("\"SERVER\" = :SERVER, \"FILES\" = :FILES,");
qryEditRule->SQL->Add("\"REMOTEPATH\" = :REMOTEPATH,");
qryEditRule->SQL->Add("\"DELETEFILES\" = :DELETEFILES,");
qryEditRule->SQL->Add("\"SAVEFILES\" = :SAVEFILES, \"SAVEPATHS\" = :SAVEPATHS,");
qryEditRule->SQL->Add("\"ZIPFILES\" = :ZIPFILES,");
qryEditRule->SQL->Add("\"ZIPFILENAME\" = :ZIPFILENAME,");
qryEditRule->SQL->Add("\"INTERVAL\" = :INTERVAL,");
qryEditRule->SQL->Add("\"CHECKTIMES\" = :CHECKTIMES,");
qryEditRule->SQL->Add("\"TRAVERSEDIRS\" = :TRAVERSEDIRS,");
qryEditRule->SQL->Add("\"SHOWALERT\" = :SHOWALERT");
qryEditRule->SQL->Add("WHERE \"ID\" = :ID");*/
qryEditRule->ParamByName("NAME")->AsString = GetName();
qryEditRule->ParamByName("ENABLED")->AsBoolean = GetEnabled();
qryEditRule->ParamByName("TYPE")->AsInteger = (int)GetType();
qryEditRule->ParamByName("SERVER")->AsInteger = GetServer();
qryEditRule->ParamByName("FILES")->AsString = Files->CommaText;
qryEditRule->ParamByName("DELETEFILES")->AsBoolean = GetDeleteFiles();
qryEditRule->ParamByName("REMOTEPATH")->AsString = GetRemotePath();
qryEditRule->ParamByName("SAVEFILES")->AsBoolean = GetSaveFiles();
qryEditRule->ParamByName("SAVEPATHS")->AsString = SavePaths->CommaText;
qryEditRule->ParamByName("ZIPFILES")->AsBoolean = GetZipFiles();
qryEditRule->ParamByName("ZIPFILENAME")->AsString = GetZipFileName();
qryEditRule->ParamByName("INTERVAL")->AsInteger = GetInterval();
qryEditRule->ParamByName("CHECKTIMES")->AsString = CheckTimes->CommaText;
qryEditRule->ParamByName("TRAVERSEDIRS")->AsBoolean = GetTraverseDirs();
qryEditRule->ParamByName("SHOWALERT")->AsBoolean = GetShowAlert();
qryEditRule->ParamByName("ID")->AsInteger = GetID();
try {
//qryEditRule->ExecSQL();
qryEditRule->ExecProc();
qryEditRule->Connection->Commit();
} catch (Exception &E) {
ShowMessage(E.Message);
qryEditRule->Connection->Rollback();
return;
}
[/syntax]
If this code is ran using TZStoredProc then when I closed the program and the TZConnection is destroyed I get an access violation in fbclient.dll. I've attached a stack trace of the exception.
I though it might be becuase I was instantiating it programatically but even if I drop the component onto a form and use that, the same thing happens. And using TZQuery doesn't create the same problem. Using normal pointers doesn't make a difference either.
Any ideas what could be going wrong?
I'm using BCB 6 update 4 and ZeosLib 6.5.1 alpha.
TIA
EDIT:
I also get an invalid staement handle exception, although it doesn't always happen. Stack trace for that is attached as well
Access violation when using TZStoredProc
Moderators: gto, cipto_kh, EgonHugeist
Access violation when using TZStoredProc
You do not have the required permissions to view the files attached to this post.
I'm still trying to figure this out and I've run into something I don't understand
In the destructor for TZAbstractRODataset it calls SetConnection(nil) which I would expect would then call TZConnection.UnregisterDataSet so that when the TZConnection is destroyed it doesn't try and delete something that has already been destroyed.
Shouldn't SetConnection(nil) call TZConnection.UnregisterDataSet? Something like...
TIA
Code: Select all
procedure TZAbstractRODataset.SetConnection(Value: TZConnection);
begin
if FConnection <> Value then
begin
if Active then Close;
Statement := nil;
if FConnection <> nil then
FConnection.UnregisterDataSet(Self);
FConnection := Value;
if FConnection <> nil then
FConnection.RegisterDataSet(Self);
end;
end;
Shouldn't SetConnection(nil) call TZConnection.UnregisterDataSet? Something like...
Code: Select all
procedure TZAbstractRODataset.SetConnection(Value: TZConnection);
begin
if FConnection <> Value then
begin
if Active then Close;
Statement := nil;
if Value = nil then
FConnection.UnregisterDataSet(Self);
FConnection := Value;
if FConnection <> nil then
FConnection.RegisterDataSet(Self);
end;
end;