Я хочу показать rootid и корневое имя для строк данных
Цитата:Я хочу показать RootID и корневое имя для строк данных
Что я уже пробовал:
Imports System.Data.SqlClient Public Class Treeaccount Dim con As New SqlConnection("Data Source=FASERVER\YSEFA;Initial Catalog=ECBSQL;Integrated Security=True") Dim da As New SqlDataAdapter Private Sub Treeaccount_Load(sender As Object, e As EventArgs) Handles MyBase.Load Create_TV() End Sub Private Sub Create_TV() TV.Nodes.Clear() Dim sql As String = "select * from tree where parentRoot=-1 order BY ParentRoot" Dim dt As DataTable = RunSql(sql) Dim TVN As New TreeNode(dt.Rows(0)("RootName")) TVN.Tag = dt.Rows(0)("RootID") TV.Nodes.Add(TVN) nodechild(TVN) TV.ExpandAll() TV.SelectedNode = TV.Nodes(0) End Sub Private Sub nodechild(Tnode As TreeNode) Dim dt As DataTable = RunSql("select * from tree where parentRoot=" & Tnode.Tag) For Each dr As DataRow In dt.Rows Dim TVN As New TreeNode(dr("RootName")) TVN.Tag = dr("RootID") Tnode.Nodes.Add(TVN) nodechild(TVN) Next End Sub Private Function RunSql(SQL As String) As DataTable Dim dt As New DataTable da = New SqlDataAdapter(SQL, con) da.Fill(dt) Return dt End Function Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles RootID.TextChanged End Sub Private Sub NewBut_Click(sender As Object, e As EventArgs) Handles NewBut.Click RootID.Text = "" RootName.Text = "" ParentRoot.Text = TV.SelectedNode.Tag RootID.Focus() End Sub Private Sub savebut_Click(sender As Object, e As EventArgs) Handles savebut.Click Dim cmd As New SqlCommand("insert Into Tree values(@RootID,@RootName,@ParentRoot)", con) cmd.Parameters.Add("@RootID", SqlDbType.NVarChar, 15).Value = RootID.Text cmd.Parameters.Add("@RootName", SqlDbType.NVarChar, 255).Value = RootName.Text cmd.Parameters.Add("@ParentRoot", SqlDbType.NVarChar, 9).Value = ParentRoot.Text If con.State = ConnectionState.Closed Then con.Open() cmd.ExecuteNonQuery() con.Close() Create_TV() End Sub Private Sub TV_AfterSelect(sender As Object, e As TreeViewEventArgs) Handles TV.AfterSelect RootID.Text = TV.SelectedNode.Tag RootName.Text = TV.SelectedNode.Text End Sub End Class
CHill60
В чем же проблема?
Member 13694538
Я хочу показать RootID и корневое имя вместе в treeview
CHill60
Как и в этом случае
Dim TVN As New TreeNode(dt.Rows(0)("RootName") & dt.Rows(0)("RootID"))?
Member 13694538
Спасибо Вам за вашу помощь
CHill60
Тогда я опубликую это как решение