Imports System.Data Imports System.Data.SqlClient Imports Microsoft.Web.UI.WebControls Imports System.Windows.Forms.TreeNode Public Class TreeView_Test Inherits System.Web.UI.Page Protected WithEvents TreeView_Test As Microsoft.Web.UI.WebControls.TreeView Protected WithEvents label1_affiche_associé As System.Web.UI.WebControls.Label Protected WithEvents Label2_affiche_associé As System.Web.UI.WebControls.Label Sub Page_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim sConnString As String "Data Source localhost ; Initial Catalog =THESAURUS ; User Id =""; Password=""; integrated security = SSPI" Dim objConn As New SqlConnection(sConnString) objConn.Open() Dim objDS As New DataSet() Dim dt1 As DataTable Dim dt2 As DataTable Dim dt3 As DataTable Dim i As Integer Dim sbuffer1 As String Dim sbuffer2 As String 'creation(d) 'un Adapter qui se charge des communications entre le Dataset et la source de données Dim da1 As New SqlDataAdapter("SELECT T1.Lib_TERME As Lib_Parent, T2.Lib_TERME as Lib_Enfant FROM TERME T1, TERME T2, ASSOCIES WHERE(T1.ID_TERME ASSOCIES.ID_TERME_SOURCE_A)and T2.ID_TERMEASSOCIES.ID_TERME_ASSOCIE ", objConn) da1.Fill(objDS, "TERME") dt1 = objDS.Tables("TERME") objConn.Close() 'création des types de données du tree view Dim nodeTERME As TreeNode Dim rowTERME As DataRow = objDS.Tables(0).Rows(0) Dim nodeTERME1 As TreeNode Dim rowTERME1 As DataRow 'Dim childrow As DataRow = objDS.Tables(1).Rows(0) For Each rowTERME In objDS.Tables(0).Rows If Not (rowTERME.IsNull(objDS.Tables(0).Columns(0))) Then nodeTERME = New TreeNode() nodeTERME.Text = rowTERME("Lib_Parent") TreeView_Test.Nodes.Add(nodeTERME) nodeTERME1 = New TreeNode() nodeTERME1.Text = rowTERME("Lib_Enfant") nodeTERME.Nodes.Add(nodeTERME1) 'End If End If 'End If Next End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question