unit uDb2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
DB, ADODB, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Label1: TLabel;
Button2: TButton;
ADOConnection1: TADOConnection;
Memo1: TMemo;
Label2: TLabel;
Button3: TButton;
ADODataSet1: TADODataSet;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
myWako : TADOTable;
const
user :
string = '
myUser';
passWord :
string = '
myPassword';
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ADOConnection1.ConnectionString :=
'
Provider=MSDASQL;'
+'
Persist Security Info=False;'
+'
User ID='+user+'
;'
+'
Password='+passWord+'
;'
+'
Data Source=rhdbd_16;'
+'
EXTCOLINFO=1;'
+'
Driver=iSeries Access ODBC Driver;'
+'
Initial Catalog=VWWE400;'
+'
DBQ=C:\Programme\Borland\Delphi7\Projects\DB\AS400.mdb;'
+'
Mode=Read;';
Memo1.Lines.Append(ADOConnection1.ConnectionString);
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if assigned(myWako)
then
begin
myWako.Active := False;
myWako.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if ADOConnection1.Connected
then ADOConnection1.Close
else ADOConnection1.Open(user,passWord);
if ADOConnection1.Connected
then Button1.Caption := '
DisConnect'
else Button1.Caption := '
Connect';
end;
procedure TForm1.Button2Click(Sender: TObject);
var
fieldNames: TStrings;
begin
memo1.Clear;
fieldNames := TStringList.Create;
ADOConnection1.GetFieldNames('
WAKO', fieldNames);
Label1.Caption := intToStr(fieldNames.Count)+'
tFields in WAKO available';
Memo1.Lines.Clear;
Memo1.Lines.AddStrings(fieldNames);
fieldNames.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
indexList: TStrings;
begin
indexList := TStringList.Create;
ADODataSet1.GetIndexNames(indexList);
memo1.Lines.AddStrings(indexList);
indexList.Free;
end;
end.