浪
浪青
Unregistered / Unconfirmed
GUEST, unregistred user!
大家好!我在学习用delphi建立动态数据库这一部分,在这作拉个实验,可提示出错,大家可以
帮我改正么?
****************NO1:
procedure TForm1.createtable(dbname, tblname: string; tbltype: ttabletype);
begin
tbl:=ttable.Create(application);
with tbl do
begin
active:=false;
databasename:=dbname;
tablename:=tblname;
tabletype:=tbltype;
with fielddefs do
begin
clear;
add('worknum',ftstring,10,true);
add('workname',ftstring,10,true);
add('ac',ftstring,3,false);
add('am',ftstring,3,false);
add('ljm',ftstring,3,true);
add('ljc',ftstring,3,true);
end;
// 假如无主键
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
createtable('tjbiaos','tjbiao1',ttdefault);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if tbl.DatabaseName<>null then
if tbl.TableName<>null then
tbl.Active :=true;
end;
//提示错误为:BDEerror with message 'unknownn database alias:tjbiaos';
*********************************NO2:
还有用SQL在DELPHI里建立视图后,没有别名,怎么用Table等一些控件来使用他呢?
帮我改正么?
****************NO1:
procedure TForm1.createtable(dbname, tblname: string; tbltype: ttabletype);
begin
tbl:=ttable.Create(application);
with tbl do
begin
active:=false;
databasename:=dbname;
tablename:=tblname;
tabletype:=tbltype;
with fielddefs do
begin
clear;
add('worknum',ftstring,10,true);
add('workname',ftstring,10,true);
add('ac',ftstring,3,false);
add('am',ftstring,3,false);
add('ljm',ftstring,3,true);
add('ljc',ftstring,3,true);
end;
// 假如无主键
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
createtable('tjbiaos','tjbiao1',ttdefault);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if tbl.DatabaseName<>null then
if tbl.TableName<>null then
tbl.Active :=true;
end;
//提示错误为:BDEerror with message 'unknownn database alias:tjbiaos';
*********************************NO2:
还有用SQL在DELPHI里建立视图后,没有别名,怎么用Table等一些控件来使用他呢?