mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 11:40:35 +02:00
New files for FBAdmin component, issue #22036
git-svn-id: trunk@37307 -
This commit is contained in:
parent
f5d9115598
commit
06f818ff0d
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -2268,6 +2268,7 @@ components/sqldb/Makefile.compiled svneol=native#text/plain
|
||||
components/sqldb/Makefile.fpc svneol=native#text/plain
|
||||
components/sqldb/design/registersqldb.bat svneol=native#text/x-msdos-program
|
||||
components/sqldb/design/registersqldb.txt svneol=native#text/plain
|
||||
components/sqldb/design/tfbadmin.png -text svneol=unset#image/png
|
||||
components/sqldb/design/tibconnection.png -text svneol=unset#image/png
|
||||
components/sqldb/design/tmssqlconnection.png -text svneol=unset#image/png
|
||||
components/sqldb/design/tmysql40connection.png -text svneol=unset#image/png
|
||||
@ -3771,6 +3772,11 @@ examples/exploremenu/exploreidemenu.lpk svneol=native#text/plain
|
||||
examples/exploremenu/exploreidemenu.pas svneol=native#text/plain
|
||||
examples/exploremenu/frmexploremenu.lfm svneol=native#text/plain
|
||||
examples/exploremenu/frmexploremenu.pas svneol=native#text/plain
|
||||
examples/fbadmin/fbadmindemo.ico -text svneol=unset#image/x-icon
|
||||
examples/fbadmin/fbadmindemo.lpi svneol=native#text/plain
|
||||
examples/fbadmin/fbadmindemo.lpr svneol=native#text/plain
|
||||
examples/fbadmin/formunit.lfm svneol=native#text/plain
|
||||
examples/fbadmin/formunit.pas svneol=native#text/plain
|
||||
examples/fontenum/fontenumeration.lpi svneol=native#text/plain
|
||||
examples/fontenum/fontenumeration.lpr svneol=native#text/pascal
|
||||
examples/fontenum/mainunit.lfm svneol=native#text/plain
|
||||
|
BIN
components/sqldb/design/tfbadmin.png
Normal file
BIN
components/sqldb/design/tfbadmin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
examples/fbadmin/fbadmindemo.ico
Normal file
BIN
examples/fbadmin/fbadmindemo.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
94
examples/fbadmin/fbadmindemo.lpi
Normal file
94
examples/fbadmin/fbadmindemo.lpi
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="fbadmindemo"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="SQLDBLaz"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="fbadmindemo.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fbadmindemo"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="formunit.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="formunit"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="fbadmindemo"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
21
examples/fbadmin/fbadmindemo.lpr
Normal file
21
examples/fbadmin/fbadmindemo.lpr
Normal file
@ -0,0 +1,21 @@
|
||||
program fbadmindemo;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, formunit
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
105
examples/fbadmin/formunit.lfm
Normal file
105
examples/fbadmin/formunit.lfm
Normal file
@ -0,0 +1,105 @@
|
||||
object Form1: TForm1
|
||||
Left = 238
|
||||
Height = 523
|
||||
Top = 145
|
||||
Width = 609
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 523
|
||||
ClientWidth = 609
|
||||
LCLVersion = '1.1'
|
||||
object Host: TLabeledEdit
|
||||
Left = 24
|
||||
Height = 23
|
||||
Top = 24
|
||||
Width = 80
|
||||
EditLabel.AnchorSideLeft.Control = Host
|
||||
EditLabel.AnchorSideRight.Control = Host
|
||||
EditLabel.AnchorSideRight.Side = asrBottom
|
||||
EditLabel.AnchorSideBottom.Control = Host
|
||||
EditLabel.Left = 24
|
||||
EditLabel.Height = 16
|
||||
EditLabel.Top = 5
|
||||
EditLabel.Width = 80
|
||||
EditLabel.Caption = 'Host'
|
||||
EditLabel.ParentColor = False
|
||||
TabOrder = 0
|
||||
Text = '127.0.0.1'
|
||||
end
|
||||
object Port: TLabeledEdit
|
||||
Left = 24
|
||||
Height = 23
|
||||
Top = 80
|
||||
Width = 80
|
||||
EditLabel.AnchorSideLeft.Control = Port
|
||||
EditLabel.AnchorSideRight.Control = Port
|
||||
EditLabel.AnchorSideRight.Side = asrBottom
|
||||
EditLabel.AnchorSideBottom.Control = Port
|
||||
EditLabel.Left = 24
|
||||
EditLabel.Height = 16
|
||||
EditLabel.Top = 61
|
||||
EditLabel.Width = 80
|
||||
EditLabel.Caption = 'Port'
|
||||
EditLabel.ParentColor = False
|
||||
TabOrder = 1
|
||||
Text = '3050'
|
||||
end
|
||||
object User: TLabeledEdit
|
||||
Left = 136
|
||||
Height = 23
|
||||
Top = 24
|
||||
Width = 80
|
||||
EditLabel.AnchorSideLeft.Control = User
|
||||
EditLabel.AnchorSideRight.Control = User
|
||||
EditLabel.AnchorSideRight.Side = asrBottom
|
||||
EditLabel.AnchorSideBottom.Control = User
|
||||
EditLabel.Left = 136
|
||||
EditLabel.Height = 16
|
||||
EditLabel.Top = 5
|
||||
EditLabel.Width = 80
|
||||
EditLabel.Caption = 'User'
|
||||
EditLabel.ParentColor = False
|
||||
TabOrder = 2
|
||||
Text = 'SYSDBA'
|
||||
end
|
||||
object Password: TLabeledEdit
|
||||
Left = 136
|
||||
Height = 23
|
||||
Top = 80
|
||||
Width = 80
|
||||
EditLabel.AnchorSideLeft.Control = Password
|
||||
EditLabel.AnchorSideRight.Control = Password
|
||||
EditLabel.AnchorSideRight.Side = asrBottom
|
||||
EditLabel.AnchorSideBottom.Control = Password
|
||||
EditLabel.Left = 136
|
||||
EditLabel.Height = 16
|
||||
EditLabel.Top = 61
|
||||
EditLabel.Width = 80
|
||||
EditLabel.Caption = 'Password'
|
||||
EditLabel.ParentColor = False
|
||||
TabOrder = 3
|
||||
Text = 'masterkey'
|
||||
end
|
||||
object ConnectButton: TButton
|
||||
Left = 276
|
||||
Height = 25
|
||||
Top = 80
|
||||
Width = 75
|
||||
Caption = 'Connect'
|
||||
OnClick = ConnectButtonClick
|
||||
TabOrder = 4
|
||||
end
|
||||
object OutputMemo: TMemo
|
||||
Left = 22
|
||||
Height = 337
|
||||
Top = 137
|
||||
Width = 577
|
||||
ScrollBars = ssAutoBoth
|
||||
TabOrder = 5
|
||||
end
|
||||
object FBAdmin1: TFBAdmin
|
||||
Protocol = IBSPLOCAL
|
||||
UseExceptions = False
|
||||
left = 392
|
||||
top = 16
|
||||
end
|
||||
end
|
126
examples/fbadmin/formunit.pas
Normal file
126
examples/fbadmin/formunit.pas
Normal file
@ -0,0 +1,126 @@
|
||||
unit formunit;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FBAdmin, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ExtCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
ConnectButton: TButton;
|
||||
FBAdmin1: TFBAdmin;
|
||||
Host: TLabeledEdit;
|
||||
OutputMemo: TMemo;
|
||||
User: TLabeledEdit;
|
||||
Password: TLabeledEdit;
|
||||
Port: TLabeledEdit;
|
||||
procedure ConnectButtonClick(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
ibconnection { for EIBDatabaseError};
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.ConnectButtonClick(Sender: TObject);
|
||||
var
|
||||
Users: TStringList;
|
||||
// For filling user details:
|
||||
GroupName,FirstName,MiddleName,LastName:string;
|
||||
UserID, GroupID: longint;
|
||||
begin
|
||||
OutputMemo.Lines.Clear;
|
||||
FBAdmin1.Host:=Host.Text;
|
||||
try
|
||||
FBAdmin1.Port:=StrToInt(Port.Text);
|
||||
except
|
||||
OutputMemo.Lines.Add('Error setting port to '+Port.Text+'. Using 3050 instead.');
|
||||
FBAdmin1.Port:=3050; //a default Firebird port
|
||||
end;
|
||||
|
||||
FBAdmin1.User:=User.Text;
|
||||
FBAdmin1.Password:=Password.Text;
|
||||
// Big chance server supports TCP/IP
|
||||
// Change this if you use embedded.
|
||||
FBAdmin1.Protocol:=IBSPTCPIP;
|
||||
|
||||
FBAdmin1.UseExceptions:=true;
|
||||
try
|
||||
// Make sure we close off previous connections.
|
||||
try
|
||||
FBAdmin1.DisConnect;
|
||||
except
|
||||
// This will generate an exception if we're not connected.
|
||||
// Ignore it.
|
||||
end;
|
||||
FBAdmin1.Connect;
|
||||
|
||||
// Shamelessly copied from the FPC example.
|
||||
// Note that backups are omitted in this example...
|
||||
// FBadmin allows lets you run backups/restores on the server.
|
||||
OutputMemo.Lines.Add('Server type: '+FBAdmin1.ServerImplementation);
|
||||
OutputMemo.Lines.Add('Server version: '+FBAdmin1.ServerVersion);
|
||||
// Handy to know for backup purposes...
|
||||
OutputMemo.Lines.Add('Server root directory: '+FBAdmin1.ServerRootDir);
|
||||
Users:=TStringList.Create;
|
||||
try
|
||||
if FBAdmin1.GetUsers(Users) then
|
||||
OutputMemo.Lines.Add('List of users: '+Users.Text)
|
||||
else
|
||||
OutputMemo.Lines.Add('Sorry, could not get user list.');
|
||||
finally
|
||||
Users.Free;
|
||||
end;
|
||||
|
||||
|
||||
// Get details for current user:
|
||||
if FBAdmin1.GetUser(FBAdmin1.User,GroupName,FirstName,MiddleName,LastName,UserID, GroupID) then
|
||||
begin
|
||||
OutputMemo.Lines.Add('Name: '+FBAdmin1.User);
|
||||
OutputMemo.Lines.Add('Full name: '+Trim(Trim(FirstName+Trim(' '+MiddleName)+' ')+LastName));
|
||||
OutputMemo.Lines.Add('User ID: '+IntToStr(UserID));
|
||||
OutputMemo.Lines.Add('Group: '+GroupName);
|
||||
OutputMemo.Lines.Add('Group ID: '+IntToStr(GroupID));
|
||||
end
|
||||
else
|
||||
OutputMemo.Lines.Add('Sorry, could not get user details for '+FBAdmin1.User);
|
||||
|
||||
OutputMemo.Lines.Add('Database log:');
|
||||
if FBAdmin1.GetDatabaseLog then
|
||||
begin
|
||||
OutputMemo.Lines.AddStrings(FBAdmin1.Output);
|
||||
end
|
||||
else
|
||||
OutputMemo.Lines.Add('Could not get database log, sorry.');
|
||||
// Component will disconnect automatically.
|
||||
except
|
||||
on B: EIBDatabaseError do
|
||||
begin
|
||||
OutputMemo.Lines.Add('Database error: '+B.ClassName+'/'+B.Message+
|
||||
'. GDS error code: '+IntToStr(B.GDSErrorCode));
|
||||
end;
|
||||
on E: Exception do
|
||||
begin
|
||||
OutputMemo.Lines.Add('Exception: '+E.ClassName+'/'+E.Message);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user