|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
4-1.rar
(15.55 KB, 下载次数: 6)
Sub 案例41()
Dim cnn As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim ws As Worksheet
Dim Sql As String
'建立与工作簿的连接
With cnn
.Provider = "microsoft.ace.oledb.12.0"
.ConnectionString = "Extended Properties=Excel 12.0;" _
& "Data Source=" & ThisWorkbook.FullName
.Open
End With
Sql = "insert into [合同信息$] values('GO-20190301','城市污水处理','西海水处理新材料有限公司','300000',#3/16/2019#,#7/20/2019#)"
rs.Open Sql, cnn, adOpenKeyset, adLockOptimistic
'复制汇总结果
MsgBox "数据添加成功!"
rs.Close
cnn.Close
Set rs = Nothing
Set cnn = Nothing
End Sub
|
|