vb如何查询数据库记录是否存在
我用的是adodc控件Ado3.RecordSource="select*from借出记录where编号='"+Text1.Text+"'"IfText1.Text=""...
我用的是adodc控件
Ado3.RecordSource = "select * from 借出记录 where 编号='" + Text1.Text + "'"
If Text1.Text = "" Then
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
Ado3.Refresh
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
End If
当点击按钮后实行查询,并把字段数据输出到文本框中,但如果记录不存在则会出错,请问该如何补充? 展开
Ado3.RecordSource = "select * from 借出记录 where 编号='" + Text1.Text + "'"
If Text1.Text = "" Then
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
Ado3.Refresh
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
End If
当点击按钮后实行查询,并把字段数据输出到文本框中,但如果记录不存在则会出错,请问该如何补充? 展开
展开全部
Ado3.RecordSource = "select * from 借出记录 where 编号='" + Text1.Text + "'"
Ado3.Refresh
if rs.eof = true then
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
else
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
End If
Ado3.Refresh
if rs.eof = true then
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
else
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
End If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Ado3.RecordSource = "select * from 借出记录 where 编号='" + Text1.Text + "'"
if not rs.eof then
If Text1.Text = "" Then
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
Ado3.Refresh
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
End If
else
response.write "没有该记录!"
end if
if not rs.eof then
If Text1.Text = "" Then
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
Ado3.Refresh
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
End If
else
response.write "没有该记录!"
end if
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Ado3.RecordSource = "select * from 借出记录 where 编号='" + Text1.Text + "'"
If Text1.Text = "" Then
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
Ado3.Refresh
If Not Ado3.Recordset.EOF Then
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
Else
MsgBox"记录不存在!"
End If
End If
If Text1.Text = "" Then
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
Ado3.Refresh
If Not Ado3.Recordset.EOF Then
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
Else
MsgBox"记录不存在!"
End If
End If
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Ado3.RecordSource = "select * from 借出记录 where 编号='" + Text1.Text + "'"
If Text1.Text = "" Then
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
Ado3.Refresh
if not ado3.recordset.eof then
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
end if
End If
If Text1.Text = "" Then
Text4.Text = ""
Text2.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Chk1.Value = 0
Else
Ado3.Refresh
if not ado3.recordset.eof then
Text4.Text = Ado3.Recordset.Fields("名称")
Text2.Text = Ado3.Recordset.Fields("读者编号")
Text5.Text = Ado3.Recordset.Fields("条形码")
Text6.Text = Ado3.Recordset.Fields("应还日期")
Text7.Text = Ado3.Recordset.Fields("押金")
end if
End If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加个条件
Ado3.Recordset.recordcount>0
Ado3.Recordset.recordcount>0
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询