那如何控制数据与数据库记录进行逐一比较?--新手问题

sunniful 2005-09-22 11:56:56
那如何控制数据与数据库记录进行逐一比较?怎么个算法啊?
...全文
163 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunniful 2005-09-22
  • 打赏
  • 举报
回复
数据库中明明不存在啊,却还执行IF语句。实在上无能
sunniful 2005-09-22
  • 打赏
  • 举报
回复
晕。我怎么调都不行啊,郁闷
xxw19820907 2005-09-22
  • 打赏
  • 举报
回复
tmpsql = "select * from SellerTable where 业务员编号='" & Trim(Text1.Text) & "'"
tmprst.Open tmpsql, cnn, adOpenDynamic, adLockOptimistic
If tmprst.EOF = False Then
MsgBox "你修改的采购员号已存,请核对后再修改!", vbCritical, "提示!"
Text1.SetFocus
tmprst.Close
Set tmprst = Nothing
TmpcnnClose
Exit Sub
End If
tmprst.Close
Set tmprst = Nothing
sunniful 2005-09-22
  • 打赏
  • 举报
回复
我这么写有问题吗,感觉就只做第一个记录的比较,而且这句If Adodc1.Recordset.EOF Then也不做直接到Else
************************************************************************
If intRetValue = 1 Then
ShowMessage "入库读取标签成功!"
Dim nCounter As Integer
ShowMessage "显示标签读取列表:"
For nCounter = 0 To 1 'intCurrentReaderReads - 1
intmyval = Communication.GetCurrentTagid(nCounter)
ShowMessage intmyval

Adodc1.RecordSource = "select * from 商品信息表 where Trim(商品EPC码)='" + Trim(intmyval) + "'"
If Adodc1.Recordset.EOF Then
myval = MsgBox("该编码已经存在,是否要添加到数据库?", vbYesNo, "提示!")
If myval = vbYes Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("商品EPC码") = intmyval
Adodc1.Recordset.Update
Adodc1.Recordset.MoveLast
End If
Else
'myval = MsgBox("是否要添加到数据库?", vbYesNo, "提示!")
'If myval = vbYes Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("商品EPC码") = intmyval
Adodc1.Recordset.Update
Adodc1.Recordset.MoveLast
' End If
End If
Next nCounter
'intCurrentReaderReads = 0
Else
ShowMessage "读取标签失败! 错误代码: " & intRetValue
End If
***************************************************************
faysky2 2005-09-22
  • 打赏
  • 举报
回复
dim cn as new adodb.connection
dim rs as new adodb.recordset
cn.open ........
set rs=cn.execute("select * from yourTableName where 条形码字段名=扫描得到的条形码")
if rs.eof then msgbox "没有相同的记录"
sunniful 2005-09-22
  • 打赏
  • 举报
回复
Q希望各位大哥给个实例看看啊
sunniful 2005-09-22
  • 打赏
  • 举报
回复
比如我有一件商品要入库,用扫描仪扫描后,得到的条码要和数据库现有的条码比较,是否有相同的,就是这么比较啊
northwolves 2005-09-22
  • 打赏
  • 举报
回复
怎么比较?SQL语句"SELECT * FROM TABLE1 WHERE FIELDX='"& YOURCHAR &"'" 判断有无记录

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧