在创建论坛版面树结构时,出现"在位置 1 处没有任何行。"以下为代码:
Imports System.Data
Imports System.Data.OleDbPartial Class _Default
Inherits System.Web.UI.Page
Private MyBBSBase As New OleDbConnection
Private MyBoardDataSet As New DataSet Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
MyBBSBase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("bbs.mdb")
MyBBSBase.Open()
Dim MyCmdBoard As New OleDbCommand
MyCmdBoard.CommandText = "select * from dv_Board"
MyCmdBoard.CommandType = CommandType.Text
MyCmdBoard.Connection = MyBBSBase
Dim MyAdpBoard As New OleDbDataAdapter(MyCmdBoard)
MyAdpBoard.Fill(MyBoardDataSet, "dv_Board")
CreateBoardTree(0)
End If
End Sub Public Sub CreateBoardTree(ByVal ParentId As Int32)
Dim MyView As DataView
MyView = MyBoardDataSet.Tables("dv_Board").DefaultView
MyView.RowFilter = "ParentID=" & ParentId If MyView.Count > 0 Then
Dim datarow As DataRowView For Each datarow In MyView
CreateBoardTree(Int32.Parse(datarow.Item("BoardId")))
Next
End If End Sub
End Class
Imports System.Data
Imports System.Data.OleDbPartial Class _Default
Inherits System.Web.UI.Page
Private MyBBSBase As New OleDbConnection
Private MyBoardDataSet As New DataSet Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
MyBBSBase.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("bbs.mdb")
MyBBSBase.Open()
Dim MyCmdBoard As New OleDbCommand
MyCmdBoard.CommandText = "select * from dv_Board"
MyCmdBoard.CommandType = CommandType.Text
MyCmdBoard.Connection = MyBBSBase
Dim MyAdpBoard As New OleDbDataAdapter(MyCmdBoard)
MyAdpBoard.Fill(MyBoardDataSet, "dv_Board")
CreateBoardTree(0)
End If
End Sub Public Sub CreateBoardTree(ByVal ParentId As Int32)
Dim MyView As DataView
MyView = MyBoardDataSet.Tables("dv_Board").DefaultView
MyView.RowFilter = "ParentID=" & ParentId If MyView.Count > 0 Then
Dim datarow As DataRowView For Each datarow In MyView
CreateBoardTree(Int32.Parse(datarow.Item("BoardId")))
Next
End If End Sub
End Class
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货