本文介绍了如何从oledbdatareader检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我数据库中的记录,但是当我尝试按条件检索它时,它没有显示记录...

Records in my db but when i am trying to retrieve it by where condition it shows no records...

*** Sample DBs
ID	catid	unit	price	pqty
2	1	pcc	$100.00	6
1	1	pcc	$109.00	1
2	2	fas	$44.00	3



***此处的代码



*** Code here

Dim ada As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter()
Dim cmds As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM salespurchase WHERE ID=" & 2, conn)
        ada.SelectCommand = cmds
                dim rdr As OleDb.OleDbDataReader = cmds.ExecuteReader

**HERE IF CONDITION DOESN'T GO INSIDE...

            If (rdr.HasRows) Then
                MsgBox("sfs")
            End If
rdr.close()



专家帮助...感谢



EXPERT HELP PLEASE...THANKS

推荐答案





***此处的代码



*** Code here

Dim ada As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter()
Dim cmds As OleDb.OleDbCommand = New OleDb.OleDbCommand("SELECT * FROM salespurchase WHERE ID=" & 2, conn)
        ada.SelectCommand = cmds
                dim rdr As OleDb.OleDbDataReader = cmds.ExecuteReader

**HERE IF CONDITION DOESN'T GO INSIDE...

            If (rdr.HasRows) Then
                MsgBox("sfs")
            End If
rdr.close()



专家帮助...谢谢



EXPERT HELP PLEASE...THANKS


这篇关于如何从oledbdatareader检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 20:41