对了,我用的数据库是sql2000,,我想用delphi做个模块来实现表的创建,而不是用数据库,来建。
解决方案 »
- Delphi中TreeView的单击事件问题请教
- 如何获取HTTP里的POST的参数?
- fastReport如何直接打印(什么对话框都不准显示再消失)
- SQL Server的SQL能不能做这样的查询?
- HexToBin到底怎么用啊?
- 怎样把TImage.Canvas中已画的图抹掉??谢谢!
- 当对窗体使用了XP_form控件后,MENU控件却跑到窗体最上方了,应如何解决?在线等待..
- VB小生求delphi中winsock 的使用效果
- C++中的静态数据成员、函数,在Delphi中用什么方式实现?
- C#首席设计师Anders Hejlsberg专访(转贴)
- 为什么我的问题都没有人回答?????再问一个问题!!!!!
- 怎样才能使DBImage有Scrollbar
table :Ttable;
.....
begin
table:=ttable.creat(self);
table.databasename:='mydatabase';
table.tablename:='mytable.db';
datasource:=Tdatasource.create(self);
.....
table.fieldefs.add('id号',FTSTRING,30,FALSE);
......
sorry 我是个delphi新手,能不能将代码给我啊,
邮你一份
With dbcreatadoquery do //dbcreatadoquery is adoquery
begin
Close;
SQL.Clear;
createsql:='create table databasecheck '+
'(ID INT IDENTITY(1,1) NOT NULL ,'+
'TABLENAMEID INT NULL ,'+
'TABLENAME CHAR(50) NOT NULL,'+
'FIELDNAME CHAR(50) NOT NULL,'+
'XTYPE INT NOT NULL,'+
'LENGTH INT NOT NULL,'+
'CDEFAULT INT NULL,'+
'DEFAULTSTR CHAR(20) NULL,'+
'ISNULLABLE INT NULL,'+
'KEYSTR INT NULL,'+
'INDEXNAME CHAR(50) NULL);';
SQL.Add(createsql);
ExecSQL;
end;
with Table1 do begin
{ The Table component must not be active }
Active := False;
{ First, describe the type of table and give }
{ it a name }
DatabaseName := 'DBDEMOS';
TableType := ttParadox;
TableName := 'CustInfo';
{ Next, describe the fields in the table }
with FieldDefs do begin
Clear;
with AddFieldDef do begin Name := 'Field1';
DataType := ftInteger;
Required := True;
end;
with AddFieldDef do begin
Name := 'Field2';
DataType := ftString;
Size := 30;
end;
end;
{ Next, describe any indexes }
with IndexDefs do begin
Clear;
{ The 1st index has no name because it is
{ a Paradox primary key }
with AddIndexDef do begin Name := '';
Fields := 'Field1';
Options := [ixPrimary];
end;
with AddIndexDef do begin
Name := 'Fld2Indx';
Fields := 'Field2';
Options := [ixCaseInsensitive];
end;
end;
{ Call the CreateTable method to create the table }
CreateTable;
end;
end;