Treeview邦定數據庫的問題
用Treeview 編寫財務會計科目設定,如下樹形:科目 階次
.... 資產 0
....流動資產 1
.....現金 2
....基金 1
.......
.... 負債 0
.....流動負債 1
.....短期負債 2
...........
請各幫我看看以下程序,還要怎么樣修改: 謝謝
Try
Dim rootnode As TreeNode
Dim childnode As TreeNode
Dim sqlcnnstr As String = "server=star168;database=DB_8816;uid=sa;pwd="
Dim sqlcnn As New SqlConnection(sqlcnnstr)
sqlcnn.Open()
Dim sqlcmd As New SqlCommand("select acc_no,name,cls from accn ", sqlcnn)
Dim adp As SqlDataAdapter = New SqlDataAdapter(sqlcmd)
Dim ds As New DataSet
Dim dl As SqlDataReader = sqlcmd.ExecuteReader
While dl.Read
For i As Integer = 0 To 4
If i <> 0 Then
rootnode = tvA.Nodes.Add(dl(i), dl("acc_no").ToString & " " & dl("name").ToString)
Do While dl.Read
childnode = rootnode.Nodes.Add(dl("acc_no").ToString & " " & dl("name").ToString)
Loop
Else
rootnode = tvA.Nodes.Add(dl(i), dl("acc_no").ToString & " " & dl("name").ToString)
End If
Next
End While
Catch ex As Exception
MessageBox.Show(ex.Message, "warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
End Try
tvA.ExpandAll()
--------------------编程问答-------------------- 此問題,我已經解決了,宣佈結案. --------------------编程问答-------------------- 您好,能不能把你的解决方案写出来,谢谢! --------------------编程问答-------------------- 可不可以写出来啊?等
补充:.NET技术 , VB.NET