Changeset 21 for trunk/UDatabase.pas
- Timestamp:
- Mar 23, 2018, 3:06:47 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UDatabase.pas
r20 r21 143 143 Name: string; 144 144 Params: TDbConnectParams; 145 destructor Destroy; override; 146 function GetClient: TDbClient; 145 147 property ClientType: TDbClientType read FClientType write SetClientType; 146 148 end; … … 152 154 procedure LoadFromRegistry(Context: TRegistryContext); 153 155 procedure SaveToRegistry(Context: TRegistryContext); 154 function FindByName(Name: string): TDbConnectProfile;156 function SearchByName(Name: string): TDbConnectProfile; 155 157 end; 156 158 … … 170 172 function RegisterType(Id: Integer; Name, Title: string; 171 173 FieldType: TFieldType; FieldTypeClass: TFieldTypeSpecificClass): TDataType; 172 function FindByType(FieldType: TFieldType): TDataType;173 function FindByName(Name: string): TDataType;174 function SearchByType(FieldType: TFieldType): TDataType; 175 function SearchByName(Name: string): TDataType; 174 176 end; 175 177 … … 183 185 procedure SetConnectProfile(AValue: TDbConnectProfile); virtual; 184 186 public 185 procedure Query( DbRows: TDbRows; Text: string); virtual;187 procedure Query(Text: string; DbRows: TDbRows = nil); virtual; 186 188 procedure LoadTables(Tables: TTables); virtual; 187 189 constructor Create; virtual; … … 373 375 end; 374 376 375 function TDbConnectProfiles. FindByName(Name: string): TDbConnectProfile;377 function TDbConnectProfiles.SearchByName(Name: string): TDbConnectProfile; 376 378 var 377 379 I: Integer; … … 389 391 if FClientType = AValue then Exit; 390 392 if Assigned(FClientType) then begin 391 Params.Free;393 FreeAndNil(Params); 392 394 end; 393 395 FClientType := AValue; … … 395 397 Params := FClientType.ConnectParmasClass.Create; 396 398 end; 399 end; 400 401 destructor TDbConnectProfile.Destroy; 402 begin 403 ClientType := nil; 404 if Assigned(Params) then Params.Free; 405 inherited Destroy; 406 end; 407 408 function TDbConnectProfile.GetClient: TDbClient; 409 begin 410 Result := ClientType.DatabaseClientClass.Create; 411 Result.ConnectProfile := Self; 397 412 end; 398 413 … … 422 437 end; 423 438 424 procedure TDbClient.Query( DbRows: TDbRows; Text: string);439 procedure TDbClient.Query(Text: string; DbRows: TDbRows = nil); 425 440 begin 426 441 end; … … 482 497 end; 483 498 484 function TDataTypes. FindByType(FieldType: TFieldType): TDataType;499 function TDataTypes.SearchByType(FieldType: TFieldType): TDataType; 485 500 var 486 501 I: Integer; … … 492 507 end; 493 508 494 function TDataTypes. FindByName(Name: string): TDataType;509 function TDataTypes.SearchByName(Name: string): TDataType; 495 510 var 496 511 I: Integer; … … 510 525 DataTypes.Clear; 511 526 for I := Low(TFieldType) to High(TFieldType) do 512 if I in Types then DataTypes.Add(ADataTypes. FindByType(I));527 if I in Types then DataTypes.Add(ADataTypes.SearchByType(I)); 513 528 end; 514 529 … … 698 713 Records.Clear; 699 714 DbRows := TDbRows.Create; 700 DbClient.Query( DbRows, 'SELECT * FROM ' + Name);715 DbClient.Query('SELECT * FROM ' + Name, DbRows); 701 716 for I := 0 to DbRows.Count - 1 do begin 702 717 NewRecord := TRecord.Create; … … 723 738 Records.Clear; 724 739 DbRows := TDbRows.Create; 725 DbClient.Query( DbRows, 'SELECT COUNT(*) FROM ' + Name);740 DbClient.Query('SELECT COUNT(*) FROM ' + Name, DbRows); 726 741 if DbRows.Count = 1 then begin 727 742 RecordsCount := StrToInt(TDictionaryStringString(DbRows[0]).Items[0].Value);
Note:
See TracChangeset
for help on using the changeset viewer.