
AND前少了空格是最主要的
'// 创建ADO记录集对象Set adoRt = CreateObject("ADODB.RecordSet")
'// 设置SQL 语句
strSQL = "SELECT * FROM TMB WHERE False"
With adoRt
'// 设置需要连接数据库
.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0Data Source=D:\TM.mdb"
.CursorLocation = 3
.CursorType = 1
.LockType = 3
'// 设置SQL语句
.Source = strSQL
'// 准备打开记录集
.Open
'删除TMB表中的所有记录
if adort.recordcount<>0 then
adort.movefirst
do while not adort.eof
adort.delete
adort.movenext
loop
endif
'// 新增记录
.AddNew
'// 赋值
.Fields("TMZF").Value = Range("识别号")
'// 更新
.Update
'// 判断并关闭记录
If .State = 1 Then
.Close
End If
End With
'// 从内存中释放
Set adoRt = Nothing
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)