Advertisement
idsystems

VBNETBD_Practica11

Mar 15th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.23 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 oConexion 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", oConexion)
  9.     Dim ds As New DataSet
  10.     Dim dt As New DataTable
  11.  
  12.  
  13.     Private Sub cmdLlenar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLlenar.Click
  14.         'Utilizar los dataAdapter para llenar el DataSet con Tablas
  15.         oConexion.Open()
  16.         'da.Fill(ds, "Peliculas")
  17.         daCat.Fill(ds, "Categorias")
  18.         'daCat.Fill(dt)
  19.         oConexion.Close()
  20.  
  21.         dgCategorias.DataSource = ds.Tables(0)
  22.  
  23.     End Sub
  24.  
  25.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  26.         Try
  27.             Dim sql As String
  28.             Dim vCat As String
  29.             TextBox1.Text = dgCategorias.Item(1, dgCategorias.CurrentCell.RowIndex).Value.ToString
  30.             vCat = dgCategorias.Item(1, dgCategorias.CurrentCell.RowIndex).Value.ToString
  31.             sql = "SELECT * From Peliculas Where IDGenero='" & vCat & "' "
  32.             Dim daPel As New OleDbDataAdapter(sql, oConexion)
  33.             Dim dtPel As New DataTable
  34.             daPel.Fill(dtPel)
  35.             dgPeliculas.DataSource = dtPel
  36.         Catch ex As Exception
  37.         End Try
  38.  
  39.  
  40.     End Sub
  41.  
  42.     Private Sub dgCategorias_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgCategorias.CurrentCellChanged
  43.         Try
  44.             Dim sql As String
  45.             Dim vCat As String
  46.             TextBox1.Text = dgCategorias.Item(1, dgCategorias.CurrentCell.RowIndex).Value.ToString
  47.             vCat = dgCategorias.Item(1, dgCategorias.CurrentCell.RowIndex).Value.ToString
  48.             sql = "SELECT * From Peliculas Where IDGenero='" & vCat & "' "
  49.             Dim daPel As New OleDbDataAdapter(sql, oConexion)
  50.             Dim dtPel As New DataTable
  51.             daPel.Fill(dtPel)
  52.             dgPeliculas.DataSource = dtPel
  53.         Catch ex As Exception
  54.         End Try
  55.  
  56.     End Sub
  57. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement