vb.net 的datareader烦了我一晚上 原来
OleDbDataReader对象在执行之后返回的第一条记录是属性列 如
Dim readData As OleDbDataReader
readData(0) readData(1) readData(2) 返回的是诸如 id uname upassword这些属性名,而不是我们要的数据
所以最好执行一遍readData.Read()他会自动跳到下一条
如下正确用法
Dim readData As OleDbDataReader
readData = myCmd.ExecuteReader()
If readData.Read() Then
Label1.Text = readData(0).ToString() + " " + readData(1).ToString() + " " + readData(2).ToString() + readData(3).ToString()
If readData.Read() Then
Label1.Text = readData(0).ToString() + " " + readData(1).ToString() + " " + readData(2).ToString() + readData(3).ToString()
end if