B
blad_pitt
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个动态创建数据库,并动态创建表的程序,可是数据库是创建出来了,表却不行
出错提示说找不到刚创建的数据库,可BDE ADMINISTRATOR里却有啊,是不是还得刷新一下
啊,怎么刷新呢?源代码如下,请各位研究。
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, Tabnotbk, Grids, Calendar, StdCtrls, Db, DBTables, DBCtrls;
type
TForm2 = class(TForm)
TabbedNotebook1: TTabbedNotebook;
Calendar1: TCalendar;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Memo1: TMemo;
Button2: TButton;
Label4: TLabel;
Label5: TLabel;
Table1: TTable;
Label6: TLabel;
DataSource1: TDataSource;
Button4: TButton;
Button5: TButton;
Table1Name: TStringField;
Table1Passwd: TStringField;
Session1: TSession;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Calendar1Change(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
n1,n2:string;
implementation
uses mima1;
{$R *.DFM}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form1.Close;
end;
procedure TForm2.FormShow(Sender: TObject);
var
ap:tstringlist;
begin
label1.caption:=inttostr(calendar1.year)+'年';
label2.caption:=inttostr(calendar1.month)+'月';
label3.caption:=inttostr(calendar1.day)+'日';
label5.caption:=datetostr(now);
n1:=extractfiledir(application.exename);
n2:=n1+'/'+h1;
ap:=tstringlist.Create;
session1.SessionName:='session1';
session1.GetAliasNames(ap);
if(ap.indexof(mima1.h1)=-1)then
begin
createdirectory(pchar(n2),nil);
session1.AddStandardAlias(h1,n2,'paradox');
session1.SaveConfigFile;
ap.clear;
with table1 do
begin
active:=false;
databasename:=h1;
tablename:=h1+'score';
tabletype:=ttparadox;
with fielddefs do
begin
clear;
add('odate',ftdate,0,false);
add('omemo',ftmemo,1,false);
end;
createtable;
active:=true;
end;
ap.free;
end;
end;
procedure TForm2.Calendar1Change(Sender: TObject);
begin
label1.caption:=inttostr(calendar1.year)+'年';
label2.caption:=inttostr(calendar1.month)+'月';
label3.caption:=inttostr(calendar1.day)+'日';
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
calendar1.month:=calendar1.Month-1;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
calendar1.month:=calendar1.Month+1;
end;
end.
出错提示说找不到刚创建的数据库,可BDE ADMINISTRATOR里却有啊,是不是还得刷新一下
啊,怎么刷新呢?源代码如下,请各位研究。
unit main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, Tabnotbk, Grids, Calendar, StdCtrls, Db, DBTables, DBCtrls;
type
TForm2 = class(TForm)
TabbedNotebook1: TTabbedNotebook;
Calendar1: TCalendar;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Memo1: TMemo;
Button2: TButton;
Label4: TLabel;
Label5: TLabel;
Table1: TTable;
Label6: TLabel;
DataSource1: TDataSource;
Button4: TButton;
Button5: TButton;
Table1Name: TStringField;
Table1Passwd: TStringField;
Session1: TSession;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Calendar1Change(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
n1,n2:string;
implementation
uses mima1;
{$R *.DFM}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
form1.Close;
end;
procedure TForm2.FormShow(Sender: TObject);
var
ap:tstringlist;
begin
label1.caption:=inttostr(calendar1.year)+'年';
label2.caption:=inttostr(calendar1.month)+'月';
label3.caption:=inttostr(calendar1.day)+'日';
label5.caption:=datetostr(now);
n1:=extractfiledir(application.exename);
n2:=n1+'/'+h1;
ap:=tstringlist.Create;
session1.SessionName:='session1';
session1.GetAliasNames(ap);
if(ap.indexof(mima1.h1)=-1)then
begin
createdirectory(pchar(n2),nil);
session1.AddStandardAlias(h1,n2,'paradox');
session1.SaveConfigFile;
ap.clear;
with table1 do
begin
active:=false;
databasename:=h1;
tablename:=h1+'score';
tabletype:=ttparadox;
with fielddefs do
begin
clear;
add('odate',ftdate,0,false);
add('omemo',ftmemo,1,false);
end;
createtable;
active:=true;
end;
ap.free;
end;
end;
procedure TForm2.Calendar1Change(Sender: TObject);
begin
label1.caption:=inttostr(calendar1.year)+'年';
label2.caption:=inttostr(calendar1.month)+'月';
label3.caption:=inttostr(calendar1.day)+'日';
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
calendar1.month:=calendar1.Month-1;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
calendar1.month:=calendar1.Month+1;
end;
end.