|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
前辈们:我在excel中用sql语句向access录入数据时提示数据类型不匹配,应该怎样修改?我把原程序截屏,请前辈们帮忙修改一下!
代码为:
Private Sub CommandButton1_Click()
Dim conn As Object
Dim Sql$, i$
Dim nRow As Long
nRow = Sheet4.Range("a14").End(xlUp).Row
Sql = "insert into [消费记录] select * from [excel 12.0;database=" & ThisWorkbook.FullName & "].[Sheet4$a3:bl" & nRow & "]; "
Set conn = CreateObject("adodb.connection")
With conn
.Provider = "microsoft.ACE.oledb.12.0"
.ConnectionString = "Data Source =" & ThisWorkbook.Path & "\shuju.accdb"
.Open
End With
conn.Execute (Sql)
conn.Close
Set conn = Nothing
End Sub
[ 本帖最后由 baowang519 于 2011-7-16 21:06 编辑 ] |
|