vb.net中SqlDataAdapter如何上下移动记录

lxsking 2010-09-07 02:56:13
各位以前vb6可以用movenext下移一笔记录,但在vb.net中上下移动记录应该怎样做,请各位大虾指教
...全文
144 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ckp00001 2010-09-08
  • 打赏
  • 举报
回复
Dim myBinding As New BindingSource
myBinding.DataSource=GetDataSet.Tables(0)
myBinding.Position += 1
debug.writeline(mybinding.Current (0))
古今多少事 2010-09-07
  • 打赏
  • 举报
回复
Dim Bm As BindingManagerBase
Bm = Me.BindingContext(GetDataSet, "TmpTable")

if Bm.position>0 then
Bm.position-=1'上一条
end if

……
lxsking 2010-09-07
  • 打赏
  • 举报
回复
二楼这是我的代码,请指教

'读取数据 sqlserver
Public Function GetDataSet(ByVal gCnn As String, ByVal sql As String, Optional ByVal TmpTable As String = "TmpTable") As DataSet
Dim objAdapter As SqlDataAdapter
Try
objSqlConnection = New SqlConnection(gCnn) '数据库连接
objAdapter = New SqlDataAdapter(sql, objSqlConnection) '查询数据集
GetDataSet = New DataSet
objAdapter.Fill(GetDataSet, TmpTable)
objAdapter = Nothing

Catch ex As Exception
MsgBox("数据处理错误" & Err.Number & ":" & Err.Description)
End Try

End Function
兔子-顾问 2010-09-07
  • 打赏
  • 举报
回复
GetDataSet.Tables(0).Rows(0)
GetDataSet.Tables(0).Rows(1)
GetDataSet.Tables(0).Rows(...)
jason成都 2010-09-07
  • 打赏
  • 举报
回复
你用的什么啊?贴代码看下你用的哪种方法
lxsking 2010-09-07
  • 打赏
  • 举报
回复
'读取数据 sqlserver
Public Function GetDataSet(ByVal gCnn As String, ByVal sql As String, Optional ByVal TmpTable As String = "TmpTable") As DataSet
Dim objAdapter As SqlDataAdapter
Try
objSqlConnection = New SqlConnection(gCnn) '数据库连接
objAdapter = New SqlDataAdapter(sql, objSqlConnection) '查询数据集
GetDataSet = New DataSet
objAdapter.Fill(GetDataSet, TmpTable)
objAdapter = Nothing

Catch ex As Exception
MsgBox("数据处理错误" & Err.Number & ":" & Err.Description)
End Try

End Function
wuyq11 2010-09-07
  • 打赏
  • 举报
回复
objdset1.Tables(0).Rows(i)(1)
Dim pos As Integer
pos = Me.BindingContext(Dataset1, "table1").Position
If pos > 0 Then
Me.BindingContext(Dataset1, "table1").Position = pos - 1
Bindingsource1.Position = Me.BindingContext(Dataset1, "table1").Position
End If
兔子-顾问 2010-09-07
  • 打赏
  • 举报
回复
.net返回的是数据集合,按下标访问就可以了。如果用游标读取,再次调用读取方法即可。
你贴出你现在的代码,才知道你如何读取的。

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧