模仿帮助事例进行测试,发现总是先读第二条表记录,是什么原因,应该如何处理?原事例如下:
'查询没有排序
Dim queryString As String = "Select * From 表名"
Public Sub ReadData(ByVal connectionString As String)
Dim queryString As String = _
"SELECT OrderID, CustomerID FROM Orders"
Using connection As New OracleConnection(connectionString)
Dim command As New OracleCommand(queryString, connection)
connection.Open()
Dim reader As OracleDataReader
reader = command.ExecuteReader()
' Always call Read before accessing data.
While reader.Read()
Console.WriteLine(reader.GetInt32(0) & ", " & reader.GetString(1))
End While
' Always call Close when done reading.
reader.Close()
End Using
End Sub
------解决方案--------------------
从数据库读取到缓存后,数据是随机排序的,所以取哪一条语句先也是随机的,只有你排序才会按你的规则获取数据