none
TreeView!遞回 + sql server RRS feed

  • 問題

  • 不好意思請問

    在參考範例要把原本access資料庫改成用sql sever的

    在這一段有關SQL資料庫要怎麼改!我改這樣都會出現"初始化字串的格式和開始於索引 0 的規格不相符"

    還是錯誤不在這

     

     

    '討論序入口
    Function buildMsgNode(ByRef nodes As TreeNodeCollection, ByVal uid As Integer) As TreeNode
    Dim ads As New SqlDataSource("~/app_data/討論區.mdf", "")
    ads.SelectCommand = "select * from 討論區 where uid=" & uid
    Dim dv As Data.DataView = ads.Select(New DataSourceSelectArguments)
    Dim NewNode As New TreeNode
    NewNode.Text = dv(0).Item("主題")
    NewNode.Value = dv(0).Item("uid")
    nodes.Add(NewNode)
    Return NewNode
    End Function

    '討論序內容
    Sub buildChildNode(ByRef nodes As TreeNodeCollection, ByVal uid As Integer)
    Dim ads As New SqlDataSource("~/app_data/討論區.mdf", "")
    ads.SelectCommand = "select * from 討論區 where 回應=" & uid & " order by uid "
    Dim dv As Data.DataView = ads.Select(New DataSourceSelectArguments)
    For i As Integer = 0 To dv.Count - 1
    Dim NewNode As New TreeNode
    NewNode.Text = dv(i).Item("主題")
    NewNode.Value = dv(i).Item("uid")
    buildChildNode(NewNode.ChildNodes, dv(i).Item("uid"))
    nodes.Add(NewNode)
    Next
    End Sub

    2008年6月17日 上午 10:42

解答

所有回覆