Base de datos avanzada
-
Upload
teffy-lavado-gomez -
Category
Documents
-
view
204 -
download
2
description
Transcript of Base de datos avanzada
UNIVERSIDAD NACIONAL DE TRUJILLOFACULTAD DE INGENIERÍA-ESCUELA DE INGENIERÍA DE SISTEMAS
LABORATORIO Nº 11CONSULTANDO PRODUCTOS POR CATEGORÍAS DE NORTHWIND
1. CONFIGURANDO DATASET
1.1 Menu Principal Datos Agregar nuevo origen de datos …1.2 Elegir un tipo de origen de datos: Base de datos1.3 Conectar con la base de datos Northwind1.4 Elija los objetos: Categories y de Products sólo seleccione:
1.5 Click en el botón Finalizar1.6 Mostrar el dataset en modo diseño; asi:
1.7 En el datatable Products, haremos clic derecho y elegimos: Agregar Query
MG. LUIS BOY CHAVIL Página 1
1.8 Seleccione la opción: Usar Instrucciones SQL y pulse el botón Siguiente
1.9 De igual forma, ahora seleccione la opción: “SELECT que devuelve filas” y pulse Siguiente; entonces, veremos:
MG. LUIS BOY CHAVIL Página 2
1.10 Clic al botón Siguiente y en la ventana que se muestra escribir el Nombre del Método en Rellenar un datatable: ListarProductos
1.11 Pulsamos el botón Finalizar y veremos el datatable Products; así:
1.12 A partir de la ventana Orígenes de datos arrastraremos el datatable Products al Formulario actual.
1.13 Y ahora colocaremos un objeto Cuadro Combo para las Categorías; asi:
MG. LUIS BOY CHAVIL Página 3
1.14 Elegimos el origen de datos: Categories; así:
1.15 Mostrar Miembro: CategoryName1.16 Miembro de Valor: CategoryID1.17 Haremos doble clic sobre Cbocategorias y escribiremos el siguiente
código:
Private Sub CboCategorias_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboCategorias.SelectedIndexChanged TryMe.ProductsTableAdapter.ListarProductos(Me.NorthwindDataSet.Products, Me.CboCategorias.SelectedValue) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Error") End Try End Sub
MG. LUIS BOY CHAVIL Página 4
1.18 El formulario final quedará así:
MG. LUIS BOY CHAVIL Página 5