* Patch from Ladislav Karrach to fix problems when closing TSQLQueries when the connection is not active, bug #17623

git-svn-id: trunk@17432 -
This commit is contained in:
joost 2011-05-11 20:51:32 +00:00
parent 6739cec2b9
commit 428915a90b
2 changed files with 26 additions and 4 deletions

View File

@ -962,10 +962,11 @@ begin
ODBCCursor.FBlobStreams.Clear;
{$ENDIF}
ODBCCheckResult(
SQLFreeStmt(ODBCCursor.FSTMTHandle, SQL_CLOSE),
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not close ODBC statement cursor.'
);
if ODBCCursor.FSTMTHandle <> SQL_NULL_HSTMT then
ODBCCheckResult(
SQLFreeStmt(ODBCCursor.FSTMTHandle, SQL_CLOSE),
SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not close ODBC statement cursor.'
);
end;
procedure TODBCConnection.AddFieldDefs(cursor: TSQLCursor; FieldDefs: TFieldDefs);

View File

@ -65,6 +65,7 @@ type
procedure TestDeleteAllInsertXML;
procedure TestFileNameProperty;
procedure TestCloseDatasetNoConnection; // bug 17623
end;
implementation
@ -398,6 +399,26 @@ begin
LoadDs.close;
end;
procedure TTestBufDatasetStreams.TestCloseDatasetNoConnection;
var SaveDs: TCustomBufDataset;
LoadDs: TCustomBufDataset;
Conn: TSQLConnection;
begin
SaveDs := DBConnector.GetNDataset(true,15) as TSQLQuery;
SaveDs.Open;
SaveDs.SaveToFile('Basics.xml',dfXML);
SaveDs.Close;
Conn := TSQLConnectionClass(TSQLDBConnector(DBConnector).Connection.ClassType).Create(nil);
LoadDs := TSQLQuery.Create(nil);
LoadDs.DataBase:=Conn;
LoadDs.LoadFromFile('Basics.xml');
LoadDs.Next;
LoadDs.Close;
LoadDs.Free;
Conn.Free;
end;
procedure TTestBufDatasetStreams.TestSimpleEditApplUpd;
begin
TestChangesApplyUpdates(@SimpleEditChange);