需要在VB.NET中记录的行为瓦特/ ADO帮助 [英] Need recordset behavior in VB.NET w/ADO help
本文介绍了需要在VB.NET中记录的行为瓦特/ ADO帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
VB.NET新手在这里。
VB.NET newbie here.
我已经学会(通过本网站),如何进行谈判,通过数据集:
I've learned (through this site) how to negotiate a dataset via:
For Each dRow In quanDS.Tables(0).Rows
'do something to each row
Next
现在我现在需要弄清楚遍历数据集中返回记录的子集 - 这里有我需要转换VB6的例子:
I now need to figure out now to loop through a subset of the records returned in the dataset - here's a VB6 example I need to convert:
strSQL = "select * from tblDQ order by xid, xcode, xDOS"
rsMaster.Open strSQL, conDB, adOpenDynamic, adLockOptimistic
rsMaster.MoveFirst
Do While Not rsMaster.EOF
strxID = Trim(rsMaster!xID)
strxCode = Trim(rsMaster!xcode)
dblQuan = rsMaster!units
Do While Trim(rsMaster!xID) = strxID And Trim(rsMaster!xcode) = strxCode
rsMaster!unitdif = rsMaster!units - dblQuan
rsMaster.Update
dblQuan = rsMaster!units
rsMaster.MoveNext
If rsMaster.EOF Then
Exit Do
End If
Loop
Loop
rsMaster.Close
rsMaster.Close
任何帮助都将是AP preciated!
Any help at all would be appreciated!
推荐答案
这将是pretty的直接的将其转换成一个SqlDataReader更换记录。基本上,语法是
It would be pretty straight forward to convert that to a SQLDataReader to replace the recordset. Basically, the syntax is
using conn as new sqlconnection({connection string})
using cmd as new sqlcommand("select * from tblDQ order by xid, xcode, xDOS", conn)
cmd.connection.open()
using reader as SQLDataReader = cmd.ExecuteDataReader()
while reader.read
do your thing here, referencing reader("field")
end while
end using 'dispose of the reader
end using 'dispose of teh command
end using 'close and dispose of the connection
这篇关于需要在VB.NET中记录的行为瓦特/ ADO帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文