Advertisement
idsystems

VBNETBD_Practica13

Mar 23rd, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.06 KB | None | 0 0
  1. 'Practica 13 - DataGridView con Ordenacion
  2. Imports System.Data.OleDb
  3.  
  4. Public Class Form1
  5.     'Declaramos los objetos BD que vamos a usar.
  6.     'Estamos usando una BD de Access 2003 (.MDB) llamada PELICULAS.MDB
  7.     'Que contiene varias tablas, pero para este caso, solo usamos una.
  8.     Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=peliculas.mdb;User Id=admin; Password=;")
  9.     Dim da As New OleDbDataAdapter("Select * From peliculas", cnn)
  10.     Dim ds As New DataSet
  11.     Dim dv As DataView
  12.  
  13.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  14.         ' Aqui va la ordenacion, segun el valor que tecleamos en la caja de texto izquierda
  15.         dv.Sort = Trim(TextBox1.Text)
  16.  
  17.     End Sub
  18.  
  19.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  20.         'Llenar el datagridview con tabla peliculas
  21.         da.Fill(ds)
  22.         dv = ds.Tables(0).DefaultView
  23.         DataGridView1.DataSource = dv.Table
  24.  
  25.     End Sub
  26. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement