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 cnn 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", cnn)
- 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
- cnn.Open()
- da.Fill(ds, "Peliculas")
- 'daCat.Fill(ds, "Categorias")
- daCat.Fill(dt)
- cnn.Close()
- DataGridView1.DataSource = ds.Tables(0)
- Me.ComboBox1.DataSource = dt
- Me.ComboBox1.DisplayMember = "categoria"
- Me.ComboBox1.ValueMember = "IDCategoria"
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim cat As Integer
- Dim cat2 As String
- 'cat = Val(ComboBox1.SelectedValue.ToString)
- cat2 = Trim(ComboBox1.Text)
- MsgBox("Cat=" & cat2)
- Dim da2 As New OleDbDataAdapter("SELECT * FROM Peliculas Where IDGenero='" & cat2 & "' ", cnn)
- Dim dt2 As New DataTable
- da2.Fill(dt2)
- DataGridView1.DataSource = dt2
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement