|
Sub 查询删除()
Dim mydata As String, mytable As String, SQL As String
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim i As Integer
'Worksheets("查询表").Cells.Clear '清除工作表的全部数据
mydata = ThisWorkbook.Path & "\jjamxspl.mdb" '指定数据库
mytable = "客户信息" '指定数据表
'建立与数据库的连接
Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.ACE.OLEDB.12.0;Jet OLEDB:Database Password='2012'"
.Open mydata
End With
SQL = "delete from 客户信息 where 联系人 in(select 联系人 from [Excel 8.0;Database=" & ThisWorkbook.FullName & "].[Sheet21$E$6])" _
& " and 客户编号 in(select 客户编号 from [Excel 8.0;Database=" & ThisWorkbook.FullName & "].[Sheet21$E$20])"
Set rs = New ADODB.Recordset
rs.Open SQL, cnn, adOpenKeyset, adLockOptimistic
Set rs = Nothing
zw.Close
End Sub
执行错误求解 |
|