如何解决asp.net中的数据读取器 [英] how to solve the data reader in asp.net
问题描述
如何解决数据读取器
how to solve datareader
Do While dr.Read()
Dim dataRow As DataRow = dt.NewRow()
For i As Integer = 0 To listCols.Count - 1
dataRow((CType(listCols(i), DataColumn))) = dr(i) '"<br />" & dr(i) & "<br /><br />"
Next i
dt.Rows.Add(dataRow)
Loop
当我在函数中使用此代码并在监视窗口中看到它时,它在dr.read()点中显示了第一行,在下一个点之后显示了下一行
我的问题是执行代码后,它显示的一条记录少于读取的记录.
如何解决..
在此先感谢..
when i use this code in our function and saw in watch window it shows first row in dr.read() point after next point it shows the next row
my problem is after executing the code it show the one record less than reading the record.
how to solve it..
thanks in advance..
推荐答案
看起来像在while循环之前有一个
Looks like you have a
odr.Read()
语句,这是为什么在进入while循环时它显示了第一个记录以及经过
statement before the while loop some where and that is why when you enter the while loop it shows the first record and the the moment passing
Do While dr.Read()
的那一刻,它显示了第二个记录,因此为您丢失了第一个记录.
请在while循环之前检查您的代码,并确保没有
it shows the second record hence missing the first record for you.
Please check your code before the while loop and make sure there is no
odr.Read()
use
datatable.load方法并传入datareader对象.
请参考
http://msdn.microsoft.com/en-us/library/system.data.datatable.load.aspx#Y1089 [ ^ ]
use
datatable.load method and pass in the datareader object.
Refer this
http://msdn.microsoft.com/en-us/library/system.data.datatable.load.aspx#Y1089[^]
这篇关于如何解决asp.net中的数据读取器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!