Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views

TreeView y ListView

This document describes an application that connects to a SQL Server database using ADO.NET. It uses a ListView and TreeView to display data. Two stored procedures are created - one to select distinct countries from the Customers table, and populate the TreeView, and another to select customer data filtered by country, to populate the ListView. When a country is selected in the TreeView, the second stored procedure is called to filter and display the corresponding customer records.

Uploaded by

juan992276377
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

TreeView y ListView

This document describes an application that connects to a SQL Server database using ADO.NET. It uses a ListView and TreeView to display data. Two stored procedures are created - one to select distinct countries from the Customers table, and populate the TreeView, and another to select customer data filtered by country, to populate the ListView. When a country is selected in the TreeView, the second stored procedure is called to filter and display the corresponding customer records.

Uploaded by

juan992276377
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

INSTITUTO SUPERIOR TECNOLOGICO IDAT Redes & Comunicaciones Profesor: Sierra Lian Fernando Alex APLICACIN NRO X Vista

en Ejecucin: BD: Northwind Tabla: Customers Esta aplicacin realiza una Conexin a la Base de Datos del Servidor SQL, utilizando un ListView y TreeView. Procedimiento Almacenado
Create Procedure Sp_0001 @Country Varchar(30) as Select CustomerID,CompanyName,ContactTitle,Country from Customers where Country=@Country go Exec Sp_0001 Mexico Create Procedure Sp_0002 as Select distinct Country from Customers go Exec Sp_0002

ADO .Net

INSTITUTO SUPERIOR TECNOLOGICO IDAT Redes & Comunicaciones Profesor: Sierra Lian Fernando Alex Cdigo de la Aplicacin:
Dim ObjDatos As New GestorBD Dim Condicion As String Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dt As DataTable = ObjDatos.Consultas_SQL("Sp_0002") Dim Padre As TreeNode TreeView1.Nodes.Clear() Padre = New TreeNode("Country") TreeView1.Nodes.Add(Padre) For i As Integer = 0 To dt.Rows.Count - 1 Padre.Nodes.Add(dt.Rows(i)(0).ToString()) Next Titulo() End Sub Sub Titulo() ListView1.Clear() ListView1.View = View.Details ListView1.GridLines = True ListView1.FullRowSelect = True ListView1.Columns.Add("CustomerId", 70, HorizontalAlignment.Left) ListView1.Columns.Add("CompanyName", 160, HorizontalAlignment.Left) ListView1.Columns.Add("ContactTitle", 120, HorizontalAlignment.Left) ListView1.Columns.Add("Country", 90, HorizontalAlignment.Left) End Sub

ADO .Net

INSTITUTO SUPERIOR TECNOLOGICO IDAT Redes & Comunicaciones Profesor: Sierra Lian Fernando Alex
Sub Llenar() Dim dt As DataTable = ObjDatos.Consultas_SQL("Sp_0001", Condicion) Titulo() For i As Integer = 0 To dt.Rows.Count - 1 Me.ListView1.Items.Add(dt.Rows(i)(0).ToString()) Me.ListView1.Items(i).SubItems.Add(dt.Rows(i)(1).ToString()) Me.ListView1.Items(i).SubItems.Add(dt.Rows(i)(2).ToString()) Me.ListView1.Items(i).SubItems.Add(dt.Rows(i)(3).ToString()) Next End Sub Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) If TreeView1.SelectedNode.Level = 1 Then Select Case TreeView1.SelectedNode.Parent.Text Case "Country" Condicion = TreeView1.SelectedNode.Text Llenar() End Select End If End Sub End Class

ADO .Net

You might also like