Ну, если не выходит мой проект откомпилировать, то сделай свой 1. Открой новый проект; 2. Положи на форму DBGrid, DataSource и Table; 3. DBGrid свяжи с DataSource, а DataSource с Table; 4. Сохрани проект; 5. В папку, в которую ты сохранил проект, положи свой файл BANK.DBF; 6. В коде модуля напиши процедуру для настройки. Модуль у тебя после этого должен выглядеть так:
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables, Grids, DBGrids;
type TForm1 = class(TForm) DBGrid1: TDBGrid; DataSource1: TDataSource; Table1: TTable; private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure SetLangForParadoxAndDBase; var p :TStringList; c :TConfigMode; begin p := TStringList.Create; c := Session.ConfigMode; Session.ConfigMode := cmSession; try p.Text := 'LANGDRIVER=ancyrr'^M^J'LEVEL=7'; Session.ModifyDriver('PARADOX',p); p.Text := 'LANGDRIVER=db866ru0'^M^J'LEVEL=7'; Session.ModifyDriver('DBASE',p); finally Session.ConfigMode := c; p.Free; end; end;
end.
|
7. Назначь форме обработчик OnCreate и напиши в него код для подключения к базе. Теперь модуль у тебя должен выглядеть так:
| Код | unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables, Grids, DBGrids;
type TForm1 = class(TForm) DBGrid1: TDBGrid; DataSource1: TDataSource; Table1: TTable; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure SetLangForParadoxAndDBase; var p :TStringList; c :TConfigMode; begin p := TStringList.Create; c := Session.ConfigMode; Session.ConfigMode := cmSession; try p.Text := 'LANGDRIVER=ancyrr'^M^J'LEVEL=7'; Session.ModifyDriver('PARADOX',p); p.Text := 'LANGDRIVER=db866ru0'^M^J'LEVEL=7'; Session.ModifyDriver('DBASE',p); finally Session.ConfigMode := c; p.Free; end; end;
procedure TForm1.FormCreate(Sender: TObject); begin SetLangForParadoxAndDBase; Table1.DatabaseName:= ExtractFilePath(ParamStr(0)); Table1.TableName:= 'BANK.DBF'; Table1.Open; end;
end.
|
8. Все, запускай программу. |