你是怎么新建一个 .mdb 数据库的?如: '用ADOX建立数据库与表 '引用Microsoft ADO Ext 2.5 for DDL and Security Dim cat As ADOX.Catalog Dim tbl As ADOX.Table Dim con As ADODB.Connection On Error GoTo 0 ' Create the new database. Set cat = New ADOX.Catalog cat.Create _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & DatabaseName & ";" ' Create a new table. Set tbl = New ADOX.Table tbl.Name = "TestTable" tbl.Columns.Append "FirstName", adVarWChar, 40 tbl.Columns.Append "LastName", adVarWChar, 40 tbl.Columns.Append "Birthdate", adDate tbl.Columns.Append "Weight", adInteger cat.Tables.Append tbl
'设置列可以为NULL tb1.columns("Weight").Attributes=AdColNullable '或者tb1.Columns("Weight").Properties("Jet OLEDB:Allow Zero Length") = True
' Connect to the database. Set con = cat.ActiveConnection ' Insert records. con.Execute "INSERT INTO TestTable VALUES ('Andy', 'Able', '1 Jan 1980', '150')" con.Execute "INSERT INTO TestTable VALUES ('Betty', 'Baker', #2/22/1990#, 70)" ' Close the database connection. con.Close Set con = Nothing Set tbl = Nothing Set cat = Nothing
dim db as database dim mdbfile as string'库的文件名 建库 set usedb=createdatabase(mdbfile,dbLangGeneral) 建表 USEdb.Execute "create table fileinfo(bh text(20),mc text(50),bz text(8),rq date,fh text(8))"
'用ADOX建立数据库与表
'引用Microsoft ADO Ext 2.5 for DDL and Security
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim con As ADODB.Connection On Error GoTo 0 ' Create the new database.
Set cat = New ADOX.Catalog
cat.Create _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & DatabaseName & ";" ' Create a new table.
Set tbl = New ADOX.Table
tbl.Name = "TestTable"
tbl.Columns.Append "FirstName", adVarWChar, 40
tbl.Columns.Append "LastName", adVarWChar, 40
tbl.Columns.Append "Birthdate", adDate
tbl.Columns.Append "Weight", adInteger
cat.Tables.Append tbl
'设置列可以为NULL
tb1.columns("Weight").Attributes=AdColNullable
'或者tb1.Columns("Weight").Properties("Jet OLEDB:Allow Zero Length") = True
' Connect to the database.
Set con = cat.ActiveConnection ' Insert records.
con.Execute "INSERT INTO TestTable VALUES ('Andy', 'Able', '1 Jan 1980', '150')"
con.Execute "INSERT INTO TestTable VALUES ('Betty', 'Baker', #2/22/1990#, 70)" ' Close the database connection.
con.Close
Set con = Nothing
Set tbl = Nothing
Set cat = Nothing
dim mdbfile as string'库的文件名
建库
set usedb=createdatabase(mdbfile,dbLangGeneral)
建表
USEdb.Execute "create table fileinfo(bh text(20),mc text(50),bz text(8),rq date,fh text(8))"
如果在其他电脑上是用2000版,还得转化