在创建树结构时,出现"在位置 1 没有任何行"的错误(社区搜索未找到解答)
在创建论坛版面树结构时,出现 "在位置 1 处没有任何行。 "
以下为代码:
Imports System.Data
Imports System.Data.OleDb
Partial 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