在vb.net中怎样浏览首记录 、上一条、下一条、尾记录、和数据库access 绑定的
1个回答
展开全部
一般,我都不喜欢做这样报上一条下一条,太专业的数据库操作不适合终端用户。
如果必须要做,你可以这样:按排序规则,取到健列表。保存到list中,上下条,只是改变一索引而已。
Imports System.Data.OleDb
Class BindNavigate
Dim cnn As OleDb.OleDbConnection '打开连接略
Dim lst As New List(Of Integer)
Sub New()
lst = New List(Of Integer)
index = -1
Using da As New OleDbDataAdapter("select id from mytable order by abc,def", cnn), tb As New DataTable
da.Fill(tb)
For Each row As DataRow In tb.Rows
Dim n As Integer = row(0)
lst.Add(n)
Next
If tb.Rows.Count > 0 Then CurrentIndex = 0
End Using
End Sub
Dim index As Integer Event CurrentIndexChanged()
Property CurrentIndex As Integer
Get
Return index
End Get
Set(ByVal value As Integer)
Dim b As Boolean = value <> index
index = value
If b Then RaiseEvent CurrentIndexChanged()
End Set
End Property
'当前的键值
ReadOnly Property CurrentValue As Integer
Get
Return lst(index)
End Get
End Property
Sub MoveFirst()
CurrentIndex = 0
End Sub
Sub MovePrevious()
CurrentIndex -= 1
End Sub
Sub MoveNext()
CurrentIndex += 1
End Sub
Sub MoveLast()
CurrentIndex = lst.Count - 1
End Sub
ReadOnly Property BOF
Get
Return CurrentIndex <= 0
End Get
End Property
ReadOnly Property EOF
Get
Return CurrentIndex >= lst.Count - 1
End Get
End Property
Private Sub Text_CurrentIndexChanged() Handles Me.CurrentIndexChanged
'绑定过程
End Sub
End Class
如果必须要做,你可以这样:按排序规则,取到健列表。保存到list中,上下条,只是改变一索引而已。
Imports System.Data.OleDb
Class BindNavigate
Dim cnn As OleDb.OleDbConnection '打开连接略
Dim lst As New List(Of Integer)
Sub New()
lst = New List(Of Integer)
index = -1
Using da As New OleDbDataAdapter("select id from mytable order by abc,def", cnn), tb As New DataTable
da.Fill(tb)
For Each row As DataRow In tb.Rows
Dim n As Integer = row(0)
lst.Add(n)
Next
If tb.Rows.Count > 0 Then CurrentIndex = 0
End Using
End Sub
Dim index As Integer Event CurrentIndexChanged()
Property CurrentIndex As Integer
Get
Return index
End Get
Set(ByVal value As Integer)
Dim b As Boolean = value <> index
index = value
If b Then RaiseEvent CurrentIndexChanged()
End Set
End Property
'当前的键值
ReadOnly Property CurrentValue As Integer
Get
Return lst(index)
End Get
End Property
Sub MoveFirst()
CurrentIndex = 0
End Sub
Sub MovePrevious()
CurrentIndex -= 1
End Sub
Sub MoveNext()
CurrentIndex += 1
End Sub
Sub MoveLast()
CurrentIndex = lst.Count - 1
End Sub
ReadOnly Property BOF
Get
Return CurrentIndex <= 0
End Get
End Property
ReadOnly Property EOF
Get
Return CurrentIndex >= lst.Count - 1
End Get
End Property
Private Sub Text_CurrentIndexChanged() Handles Me.CurrentIndexChanged
'绑定过程
End Sub
End Class
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
TableDI
2024-07-18 广告
2024-07-18 广告
要将两个表格中的数据进行匹配,首先确定两个表格中都存在的共同字段,如ID、姓名或特定标识符。接着,使用数据处理工具(如Excel、SQL或Python的pandas库)来执行匹配操作。在Excel中,可以通过VLOOKUP函数或数据透视表来...
点击进入详情页
本回答由TableDI提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询