我有机会参与迁移项目(VB到VB.NET)。我在RecordSet功能中感到困惑。在我们的项目中,我们根据场景采用了DataReader。但是在像dsr这样的循环情况下。 EOF。
Dim recordset As dao.RecordSet
If recordset .EOF Then
' ' msgbox "Please enter some number ", vbOKOnly, "Number Not Found"
' ' txtAdd.SetFocus
' ' Exit Sub
End If
如何将其转换为VB.NET? 要么我们需要写If Not reader.Read或If reader.Read。
对此有什么帮助吗?
答案 0 :(得分:1)
我认为你可能会追随的是以下
Dim reader As IDataReader
' <fill the reader with your query via an IDbCommand>
Dim dataFound As Boolean = false
Using reader = command.ExecuteQuery()
While reader.Read()
' <perform your data processing here>
dataFound = True
End While
If dataFound = False Then
' <Here you do your processing for the case where data was not found.>
End If
End Using
或者,如果您只是在一行数据之后,那么我们有:
Dim reader As IDataReader
' <fill the reader with your query via an IDbCommand>
Using reader = command.ExecuteQuery()
If reader.Read() Then
' <perform your data processing here>
Else
' <Here you do your processing for the case where data was not found.>
End While
End Using