下面是我编译出错的一个程序段:
Private Sub btnReadTags_Click()
Dim intRetValue As Integer
Dim intmyval As String
Dim myval As String
intRetValue = Communication.ReadAllTags(txtUseAntenna)
If intRetValue = 1 Then
ShowMessage "读取标签成功!"
Dim nCounter As Integer
ShowMessage "显示标签读取列表:"
For nCounter = 0 To 2 'intCurrentReaderReads - 1
intmyval = Communication.GetCurrentTagid(nCounter)
ShowMessage intmyval
'自动更新数据库
Adodc1.RecordSource = "select * from 商品信息表 "
'where 商品EPC码='" + Communication.GetCurrentTagid(nCounter) + "'"
'Adodc1.Refresh
If inmyval = Adodc1.Recordset.Fields("商品EPC码") Then
myval = MsgBox("该编码已经存在,是否要添加到数据库?", vbYesNo, "提示!")
If myval = vbYes Then
Adodc1.Recordset.Fields("商品EPC码") = intmyval
Adodc1.Recordset.Update
End If
Else
Adodc1.Recordset.Fields("商品EPC码") = intmyval
Adodc1.Recordset.Update
End If
Next nCounter
'intCurrentReaderReads = 0
Else
ShowMessage "读取标签失败! 错误代码: " & intRetValue
End If
End Sub
编译光标在'If inmyval = Adodc1.Recordset.Fields("商品EPC码") Then'位置上报错:“实时错误'91',对象变量或with块变量未设置"小弟刚刚学习,请各位达人赐教,不胜感激!!!
Private Sub btnReadTags_Click()
Dim intRetValue As Integer
Dim intmyval As String
Dim myval As String
intRetValue = Communication.ReadAllTags(txtUseAntenna)
If intRetValue = 1 Then
ShowMessage "读取标签成功!"
Dim nCounter As Integer
ShowMessage "显示标签读取列表:"
For nCounter = 0 To 2 'intCurrentReaderReads - 1
intmyval = Communication.GetCurrentTagid(nCounter)
ShowMessage intmyval
'自动更新数据库
Adodc1.RecordSource = "select * from 商品信息表 "
'where 商品EPC码='" + Communication.GetCurrentTagid(nCounter) + "'"
'Adodc1.Refresh
If inmyval = Adodc1.Recordset.Fields("商品EPC码") Then
myval = MsgBox("该编码已经存在,是否要添加到数据库?", vbYesNo, "提示!")
If myval = vbYes Then
Adodc1.Recordset.Fields("商品EPC码") = intmyval
Adodc1.Recordset.Update
End If
Else
Adodc1.Recordset.Fields("商品EPC码") = intmyval
Adodc1.Recordset.Update
End If
Next nCounter
'intCurrentReaderReads = 0
Else
ShowMessage "读取标签失败! 错误代码: " & intRetValue
End If
End Sub
编译光标在'If inmyval = Adodc1.Recordset.Fields("商品EPC码") Then'位置上报错:“实时错误'91',对象变量或with块变量未设置"小弟刚刚学习,请各位达人赐教,不胜感激!!!
或者是你没有设置Adodc1的ConnectionString
Adodc1的ConnectionString都设置好了。
adore.Open SQL, Connstr, adOpenDynamic, adLockBatchOptimistic