From 8a66698bc4ac18b5011d45cc75e84da07dcc6e7c Mon Sep 17 00:00:00 2001 From: joost Date: Tue, 23 Oct 2007 11:40:43 +0000 Subject: [PATCH] * TIBConnection.Dialect is read-only as it is implemened now. And public, not published. * Check if the database is connected in TIBConnection.SetDialect * Changed error-buffer size (ibconnection) * TCustomConnection.StreamedConnected is protected * Initialize TDatabase.FConnected to false git-svn-id: trunk@8913 - --- packages/fcl-db/src/database.inc | 1 + packages/fcl-db/src/db.pas | 2 +- .../src/sqldb/interbase/ibconnection.pp | 45 ++++++++++--------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/packages/fcl-db/src/database.inc b/packages/fcl-db/src/database.inc index 23e7a97be9..83b7078677 100644 --- a/packages/fcl-db/src/database.inc +++ b/packages/fcl-db/src/database.inc @@ -60,6 +60,7 @@ begin FParams:=TStringlist.Create; FDatasets:=TList.Create; FTransactions:=TList.Create; + FConnected:=False; end; destructor TDatabase.Destroy; diff --git a/packages/fcl-db/src/db.pas b/packages/fcl-db/src/db.pas index 1ce04d5fde..0e3be682c4 100644 --- a/packages/fcl-db/src/db.pas +++ b/packages/fcl-db/src/db.pas @@ -1562,6 +1562,7 @@ type procedure InternalHandleException; virtual; procedure Loaded; override; procedure SetConnected (Value : boolean); virtual; + property Streamedconnected: Boolean read FStreamedConnected write FStreamedConnected; public procedure Close; destructor Destroy; override; @@ -1571,7 +1572,6 @@ type published property Connected: Boolean read GetConnected write SetConnected; property LoginPrompt: Boolean read FLoginPrompt write FLoginPrompt; - property Streamedconnected: Boolean read FStreamedConnected write FStreamedConnected; property AfterConnect : TNotifyEvent read FAfterConnect write SetAfterConnect; property AfterDisconnect : TNotifyEvent read FAfterDisconnect write SetAfterDisconnect; diff --git a/packages/fcl-db/src/sqldb/interbase/ibconnection.pp b/packages/fcl-db/src/sqldb/interbase/ibconnection.pp index 71eab86d1c..80ed307f29 100644 --- a/packages/fcl-db/src/sqldb/interbase/ibconnection.pp +++ b/packages/fcl-db/src/sqldb/interbase/ibconnection.pp @@ -95,8 +95,8 @@ type procedure CreateDB; override; procedure DropDB; override; property BlobSegmentSize : word read FBlobSegmentSize write FBlobSegmentSize; + property Dialect : integer read GetDialect; published - property Dialect : integer read GetDialect write FDialect; property DatabaseName; property KeepConnection; property LoginPrompt; @@ -133,7 +133,7 @@ type procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS); var - buf : array [0..1024] of char; + buf : array [0..1023] of char; Msg : string; E : EIBDatabaseError; Err : longint; @@ -332,25 +332,28 @@ var Buffer : array [0..1] of byte; ResBuf : array [0..39] of byte; begin - Buffer[0] := isc_info_db_sql_dialect; - Buffer[1] := isc_info_end; - if isc_database_info(@FStatus[0], @FSQLDatabaseHandle, Length(Buffer), - pchar(@Buffer[0]), SizeOf(ResBuf), pchar(@ResBuf[0])) <> 0 then - CheckError('SetDBDialect', FStatus); - x := 0; - while x < 40 do - case ResBuf[x] of - isc_info_db_sql_dialect : - begin - Inc(x); - Len := isc_vax_integer(pchar(@ResBuf[x]), 2); - Inc(x, 2); - FDialect := isc_vax_integer(pchar(@ResBuf[x]), Len); - Inc(x, Len); - end; - isc_info_end : Break; - else - inc(x); + if Connected then + begin + Buffer[0] := isc_info_db_sql_dialect; + Buffer[1] := isc_info_end; + if isc_database_info(@FStatus[0], @FSQLDatabaseHandle, Length(Buffer), + pchar(@Buffer[0]), SizeOf(ResBuf), pchar(@ResBuf[0])) <> 0 then + CheckError('SetDBDialect', FStatus); + x := 0; + while x < 40 do + case ResBuf[x] of + isc_info_db_sql_dialect : + begin + Inc(x); + Len := isc_vax_integer(pchar(@ResBuf[x]), 2); + Inc(x, 2); + FDialect := isc_vax_integer(pchar(@ResBuf[x]), Len); + Inc(x, Len); + end; + isc_info_end : Break; + else + inc(x); + end; end; end;