Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data
- Imports System.Data.OleDb
- Public Class Form1
- 'Creacio Conexion y Adaptadores
- Dim oConexion As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=peliculas.mdb; User Id=admin;Password=;")
- 'Dim da As New OleDbDataAdapter("SELECT * FROM Peliculas", cnn)
- Dim daCat As New OleDbDataAdapter("SELECT * FROM Categorias", oConexion)
- Dim ds As New DataSet
- Dim dt As New DataTable
- Private Sub cmdLlenar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLlenar.Click
- 'Utilizar los dataAdapter para llenar el DataSet con Tablas
- oConexion.Open()
- 'da.Fill(ds, "Peliculas")
- daCat.Fill(ds, "Categorias")
- 'daCat.Fill(dt)
- oConexion.Close()
- dgCategorias.DataSource = ds.Tables(0)
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Try
- Dim sql As String
- Dim vCat As String
- TextBox1.Text = dgCategorias.Item(1, dgCategorias.CurrentCell.RowIndex).Value.ToString
- vCat = dgCategorias.Item(1, dgCategorias.CurrentCell.RowIndex).Value.ToString
- sql = "SELECT * From Peliculas Where IDGenero='" & vCat & "' "
- Dim daPel As New OleDbDataAdapter(sql, oConexion)
- Dim dtPel As New DataTable
- daPel.Fill(dtPel)
- dgPeliculas.DataSource = dtPel
- Catch ex As Exception
- End Try
- End Sub
- Private Sub dgCategorias_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgCategorias.CurrentCellChanged
- Try
- Dim sql As String
- Dim vCat As String
- TextBox1.Text = dgCategorias.Item(1, dgCategorias.CurrentCell.RowIndex).Value.ToString
- vCat = dgCategorias.Item(1, dgCategorias.CurrentCell.RowIndex).Value.ToString
- sql = "SELECT * From Peliculas Where IDGenero='" & vCat & "' "
- Dim daPel As New OleDbDataAdapter(sql, oConexion)
- Dim dtPel As New DataTable
- daPel.Fill(dtPel)
- dgPeliculas.DataSource = dtPel
- Catch ex As Exception
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement