unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DBTables,
DB, StdCtrls, Grids, DBGrids, ZTransact, ZMySqlTr,
ZQuery, ZMySqlQuery, ZConnect, ZMySqlCon, ComCtrls;
type
TForm1 =
class(TForm)
Btabanlegen: TButton;
Ehost: TEdit;
Euser: TEdit;
Epw: TEdit;
edb: TEdit;
Host: TLabel;
User: TLabel;
Label3: TLabel;
Database: TLabel;
dbmain: TZMySqlDatabase;
qrmain: TZMySqlQuery;
trmain: TZMySqlTransact;
dsmain: TDataSource;
beintragen: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Banzeigen: TButton;
procedure BtabanlegenClick(Sender: TObject);
procedure beintragenClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BtabanlegenClick(Sender: TObject);
begin
dbMain.Host:=ehost.Text;
//Server
dbMain.Login:=euser.Text;
//Benutzername
dbMain.Password:=epw.Text;
//Passwort
dbMain.Database:=edb.Text;
//Name der Datenbank
dbMain.Connected:=True;
//Verbindung herstellen
try
qrMain.SQL.Text:='
CREATE TABLE `adressbuch` ('+
'
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,'+
'
`vorname` TEXT NOT NULL,'+
'
`name` TEXT NOT NULL,'+
'
`adresse` TEXT NOT NULL,'+
'
`wohnort` TEXT NOT NULL,'+
'
`plz` INT NOT NULL'+
'
);';
qrMain.ExecSql;
finally
dbMain.Connected:=False;
end;
end;
procedure TForm1.beintragenClick(Sender: TObject);
begin
dbMain.Host:=ehost.Text;
//Server
dbMain.Login:=euser.Text;
//Benutzername
dbMain.Password:=epw.Text;
//Passwort
dbMain.Database:=edb.Text;
//Name der Datenbank
dbMain.Connected:=True;
//Verbindung herstellen
try
qrMain.SQL.Text:='
INSERT INTO `adressbuch` '+
'
(`id`, `vorname`, `name`, `adresse`, `wohnort`, `plz`)'+
'
VALUES '+
'
(''
''
, ''
'+edit1.Text+'
''
, ''
'+edit2.Text+
'
''
, ''
'+edit3.Text+'
''
, ''
'+edit4.Text+
'
''
, ''
'+edit5.Text+'
''
);';
qrMain.ExecSql;
//SQL-Statement ausführen
finally
dbMain.Connected:=False;
end;
end;
end.