瀏覽代碼

* 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 -

joost 18 年之前
父節點
當前提交
8a66698bc4
共有 3 個文件被更改,包括 26 次插入22 次删除
  1. 1 0
      packages/fcl-db/src/database.inc
  2. 1 1
      packages/fcl-db/src/db.pas
  3. 24 21
      packages/fcl-db/src/sqldb/interbase/ibconnection.pp

+ 1 - 0
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;

+ 1 - 1
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;

+ 24 - 21
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;