Advertisement
idsystems

VBNETBD_Practica10

Mar 12th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.46 KB | None | 0 0
  1. Imports System.Data
  2. Imports System.Data.OleDb
  3.  
  4. Public Class Form1
  5.     'Creacio Conexion y Adaptadores
  6.     Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=peliculas.mdb; User Id=admin;Password=;")
  7.     Dim da As New OleDbDataAdapter("SELECT * FROM Peliculas", cnn)
  8.     Dim daCat As New OleDbDataAdapter("SELECT * FROM Categorias", cnn)
  9.     Dim ds As New DataSet
  10.     Dim dt As New DataTable
  11.  
  12.  
  13.  
  14.     Private Sub cmdLlenar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLlenar.Click
  15.        
  16.         'Utilizar los dataAdapter para llenar el DataSet con Tablas
  17.         cnn.Open()
  18.         da.Fill(ds, "Peliculas")
  19.         'daCat.Fill(ds, "Categorias")
  20.         daCat.Fill(dt)
  21.         cnn.Close()
  22.  
  23.         DataGridView1.DataSource = ds.Tables(0)
  24.  
  25.         Me.ComboBox1.DataSource = dt
  26.         Me.ComboBox1.DisplayMember = "categoria"
  27.         Me.ComboBox1.ValueMember = "IDCategoria"
  28.  
  29.     End Sub
  30.  
  31.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  32.         Dim cat As Integer
  33.         Dim cat2 As String
  34.         'cat = Val(ComboBox1.SelectedValue.ToString)
  35.         cat2 = Trim(ComboBox1.Text)
  36.  
  37.         MsgBox("Cat=" & cat2)
  38.         Dim da2 As New OleDbDataAdapter("SELECT * FROM Peliculas Where IDGenero='" & cat2 & "' ", cnn)
  39.         Dim dt2 As New DataTable
  40.         da2.Fill(dt2)
  41.  
  42.         DataGridView1.DataSource = dt2
  43.  
  44.     End Sub
  45. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement