Private Sub Command1_Click()
Dim AccessDBPath As String, SheetName As String, aaa As String
Dim ExcelPath As String, AccessTable As String
Dim cat As New ADOdb.Recordset
Dim cn As New ADOdb.Connection
AccessDBPath = InputBox("请输入创建路径" & vbCrLf & _
"如:c:\aaa.mdb ", "创建数据库", "f:\考场安排.mdb")
Call CreateDatabase(AccessDBPath, 123)
SheetName = InputBox("请输入导出工作表的名称" & vbCrLf & _
"如:sheet1", , "sheet1")
ExcelPath = InputBox("请输入要导出资料的 Excel 档案路径名称" _
& vbCrLf & "如C:\book1.xls ", _
"创建数据库", "f:\考场安排.xls")
AccessTable = "考场安排"
Call ExportExcelSheetToAccess(SheetName, ExcelPath, AccessTable, AccessDBPath)
Set cn = New ADOdb.Connection
aaa = " create table time1 as select * from table where 1=2"
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=f:\考场安排.mdb;Persist Security Info=False"
cn.Open '就是这句说是有错误,找不到可安装的ISAM
Set cat = cn.Execute(aaa)
End Sub
我就是想实现先把数据从excel导入到access中,然后再对access操作,目前就是想再建一个表,让它具有和刚才生成的表相同的字段,然后再向里面加入我需要的数据
我刚学vb没几天,好多代码都是网上找的,被我拼到一块的,里面可能有不少低级错误,还要麻烦各位高手都给改正以下,谢谢了
我把下面那几句改成这样了
aaa = " create table time1 as select * from table where 1=2"
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "data source=考场安排.mdb"
cn.Open '这句没错了
Set cat = cn.Execute(aaa) '可是这句说create table中的语法错误
[此贴子已经被作者于2007-10-18 10:47:12编辑过]