请教access数据库动态生成的问题(50)

  • 主题发起人 liugaohui
  • 开始时间
L

liugaohui

Unregistered / Unconfirmed
GUEST, unregistred user!
//**********************************//程序功能:创建Access数据库和数据表//**********************************unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ComObj, ADODB, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; Path: string;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin Path := ExtractFilePath(Application.ExeName);end;//数据库创建过程procedure TForm1.Button1Click(Sender: TObject);var CreateAccess: OleVariant;begin //如果存在同名文件,则删除之 if FileExists(Path + 'A1.mdb') then begin DeleteFile(Path + 'A1.mdb'); end; CreateAccess := CreateOleObject('ADOX.Catalog'); CreateAccess.Create('Provider=Microsoft.Jet.OLEDB.4.0;Data Source= ' + Path + 'A1.mdb'); Showmessage('数据库创建成功');end;//数据表创建过程procedure TForm1.Button2Click(Sender: TObject);var ADOConn: TADOConnection; StrSQL: string;const AConnectionString = 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s';begin ADOConn := TADOConnection.create(self); ADOConn.ConnectionString := Format(AConnectionString, [Path + 'A1.mdb', '']); Strsql := 'Create Table 表1(姓名 Char(10),出生日期 DateTime,职务 Char(20), 基本工资 Int)'; ADOConn.Execute(strsql); ADOConn.Close; ADOConn.Free; Showmessage('数据表创建成功');end;end.======================================上面的动态生成的表中,出生日期 DateTime 如何定义为短日期格式呢?谢谢回复!
 
把 datetime 改成 date...
 
delphi世界qq群:23981160,希望delphi的朋友进来
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
503
import
I
顶部