'用VB创建Access表格:
'如果程序比较复杂,可添加引用:Microsoft Asctivex Data Objects 2.5 LibraryPrivate
Private Sub Command1_Click()
On Error Resume Next
db = "d:\aa.mdb"
If Dir(db) = "" Then CreateObject("ADOX.Catalog").Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & db
If Dir(db) = "" Or Err <> 0 Then If MsgBox("数据库创建失败!",48) <> vbYes Then Exit Sub
Set con = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
con.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & db
Set rs.ActiveConnection = con
rs.open "create table aaa (aa char(2),bb date,cc int)"
rs.open "insert into aaa (aa,bb,cc) values ('aa',#" & Now & "#,11)"
rs.open "select * from aaa"
If Not rs.EOF Then
For i = 0 To rs.fields.Count - 1
Print "字段名:"; rs.fields(i).Name,"字段值:"; rs.fields(i)
Next
End If
rs.Close
End Sub