Database

Delete a User from adatabase in Sql Server 2000

Delete a User from adatabase in Sql Server 2000 procedure TForm1.Button1Click(Sender: TObject); begin ADOCommand1.CommandText := ‘Use DataBaseName’; ADOCommand1.Execute; ADOCommand1.CommandText := ‘Exec SP_DropUser ‘ + QuotedStr(‘Username’); ADOCommand1.Execute; end;

Database

Add a user into a database in Sql Server 2000

Add a user into a database in Sql Server 2000 procedure TForm1.Button1Click(Sender: TObject); begin ADOCommand1.CommandText := ‘Use DataBaseName’; ADOCommand1.Execute; ADOCommand1.CommandText := ‘Exec SP_AddUser ‘ + QuotedStr(‘Username’); ADOCommand1.Execute; end;

Database

Connect To Sql Server 2000

Connect To Sql Server 2000 procedure TForm1.Button1Click(Sender: TObject); begin ADOConnection1.ConnectionString := ‘Server=Hostname;DataBase=DatabaseName’; ADOConnection1.Open(‘UserName’, ‘Password’); ADOConnection1.Connected := True; end; {* For Any Information Mail Me * Mail : Mostafa@Touska.Co.ir0

Database

Add a User’s Login in Sql Server 2000

Add a User’s Login in Sql Server 2000 procedure TForm1.Button1Click(Sender: TObject); begin ADOConnection1.Connected := True; ADOCommand1.CommandText := ‘Exec SP_AddLogin ‘ + QuotedStr(‘UserName’) + ‘,’ + QuotedStr(‘Password’) + ‘,’ + QuotedStr(‘Database Name’) + ‘,’ + QuotedStr(‘English’) […]

Database

Adapt DateTime values for SQL-Server or Access formats

{——————————————————————— Dieser Tip ist als Verbesserung zum ursprünglichen Artikel http://www.swissdelphicenter.ch/de/showcode.php?id=1423 gedacht. Die folgende Funktionen wandeln einen DateTime Wert (unabhنngig vom eingestelltem Datumsformat) in einen für den SQL-Server verstنndlichen String um. ———————————————————————- Please also take a […]

Database

Scroll within a DBGrid

Here is tip how to scroll DBGrid private OldGridProc: TWndMethod; procedure GridWindowProc(var Message: TMessage); //… procedure TForm1.FormCreate(Sender: TObject); begin OldGridProc := DBGrid1.WindowProc; DBGrid1.WindowProc := GridWindowProc; end; procedure TForm1.GridWindowProc(var Message: TMessage); var Pos: SmallInt; begin OldGridProc(Message); […]

Database

Make a HTML and TXT report component

Make a HTML and TXT report component unit LittleReport; interface uses Windows, Messages, SysUtils, Classes, DB, Graphics; const FAuthor = ‘Simone Di Cicco’; FVersion = ‘1.0’; type TLittleReport = class(TComponent) protected FDataSet: TDataSet; FWidth: Integer; […]

Database

Create a Dataset lookup field at runtime

example: create lookup field (string, size: 50) at runtime with TStringField.Create(YourDataSet) do begin FieldName := ‘FieldName’; FieldKind := fkLookup; DataSet := YourDataSet; Name := DataSet.Name + FieldName; KeyFields := ‘YourKeyFields’; LookupDataSet := YourLookupDataSet; LookupKeyFields := […]

Database

Add a Row Number in your DBGrid

1. create new blank field in dbgrid 2. rename the title with ‘No’ 3. put this code in OnDrawColumncell 4. Now your Grid has a row number procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; […]

Database

Create an Access Database (2)

Create an Access Database (2) uses ComObj; procedure TForm1.Button1Click(Sender: TObject); var AccessApp: Variant; begin AccessApp := CreateOleObject(‘Access.Application’); AccessApp.NewCurrentDatabase(‘c:\111.mdb’); AccessApp := Unassigned; end;

Database

Color a specific (conditional) cell in a DBGrid

Color a specific (conditional) cell in a DBGrid procedure TFRM_Main.DBG_MainGetCellParams(Sender: TObject; Field: TField; AFont: TFont; var Background: TColor; Highlight: Boolean); begin if (Field.AsString = ‘0’) and (Field.FullName = ‘LoadingAttn’) then begin Background := $00E69B00; AFont.Color […]

Delphi

Shape a form to a bitmap

Shape a form to a bitmap unit Unit1; interface uses Windows, Classes, SysUtils, Graphics, Forms; type TRGBArray = array[0..32767] of TRGBTriple; PRGBArray = ^TRGBArray; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private […]

Delphi

Export a TListView to a TStringGrid

Export a TListView to a TStringGrid procedure ListView2StringGrid(Listview: TListView; StringGrid: TStringGrid); const MAX_SUBITEMS = 5; var i, j: Integer; begin with ListView do for i := 0 to Items.Count – 1 do begin {Get Item […]

Delphi

Close a form animated

Close a form animated var tutup: Boolean; i: Integer; procedure TForm1.Timer1Timer(Sender: TObject); var reg1, reg2: hrgn; begin if tutup = True then begin i := i + 10; reg1 := CreateRoundRectRgn(0 + i, 0 + […]

Delphi

Reduce a form by right-clicking on the titlebar

Reduce a form by right-clicking on the titlebar type TForm1 = class(TForm) private { Private-Deklarationen } FOldHeight: Integer; procedure WMNCRButtonDown(var Msg: TWMNCRButtonDown); message WM_NCRBUTTONDOWN; public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.DFM} […]

Delphi

Make an animated application icon

Make an animated application icon var icon1: Boolean; {….} procedure TForm1.Timer1Timer(Sender: TObject); begin icon1 := not Icon1; case Icon1 of True: Application.icon := Image1.Picture.Icon; False: Application.icon := Image2.Picture.Icon; end; end; procedure TForm1.FormCreate(Sender: TObject); begin icon1 […]

Delphi

Show multiline Text in a TCombobox

Show multiline Text in a TCombobox unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) ComboBox1: TComboBox; procedure FormCreate(Sender: TObject); procedure ComboBox1MeasureItem(Control: TWinControl; Index: Integer; var Height: […]

Delphi

Create a form with rounded corners

The CreateRoundRectRgn function creates a rectangular region with rounded corners procedure TForm1.FormCreate(Sender: TObject); var rgn: HRGN; begin Form1.Borderstyle := bsNone; rgn := CreateRoundRectRgn(0,// x-coordinate of the region’s upper-left corner 0, // y-coordinate of the region’s […]

Delphi

Close a TCommonDialog automatically

It is possible to close a common dialog shown by TCommonDialog.Execute (or its overriddens) method while it is visible and application handles messages. The solution is: SendMessage(GetParent(OpenDialog1.Handle), WM_SYSCOMMAND, SC_CLOSE, 0);

Delphi

Show forms on a TScrollBox

Show forms on a TScrollBox Before you show the Form you must simply set the parent property of the form: procedure TForm1.Button1Click(Sender: TObject); begin Form2.Parent := ScrollBox1; Form2.Show; end;

Delphi

Use the AnimateWindow function

Use the AnimateWindow function The AnimateWindow function enables you to produce special effects when showing or hiding windows. procedure TForm1.Button1Click(Sender: TObject); begin Form2.BringToFront; AnimateWindow(Form2.Handle, 3000, AW_BLEND); Form2.Show; {The 3. parameter can be one or more […]

Delphi

Close a MDIChild form

Have you noticed that when you try to close a MDIChild form the form minimizes but doesn’t disappear from your Main form client area? With this tip you can learn how to really close the […]