Tema: consultas
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/05/2016, 14:54
robertocarrillo
 
Fecha de Ingreso: septiembre-2014
Mensajes: 79
Antigüedad: 9 años, 8 meses
Puntos: 0
consultas

Hola, espero anden bien....
TENGO
EL FORMULARIO:
form_Buscar.vb
Código vb:
Ver original
  1. Imports MySql.Data
  2. Imports MySql.Data.Types
  3. Imports MySql.Data.MySqlClient
  4.  
  5. Public Class form_Buscar
  6.     Private Sub form_Resultados_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  7.  
  8.     End Sub
  9.  
  10.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  11.         Dim datos As New clase_datos
  12.         datos.ente = TxtEnte.Text()
  13.         datos.mes = Val(TxtMes.Text())
  14.         datos.anio = Val(TxtAnio.Text())
  15.         datos.detalle = TxtDetalle.Text()
  16.         If Buscar(datos) Then
  17.             MsgBox("ENCONTRAMOS ALGO  " & _resultados.ToString)
  18.             ' Me.Hide()
  19.            'form_Resultados.Show()
  20.        End If
  21.     End Sub
  22. End Class

LA CLASE:
class_datos.vb
Código vb:
Ver original
  1. Public Class clase_datos
  2.     Private _id As Integer
  3.     Private _ente As String
  4.     Private _detalle As String
  5.     Private _mes As Integer
  6.     Private _anio As Integer
  7.     Private _cantidad As Integer
  8.     Private _fecha As String
  9.     Private _usr As String
  10.     Public Property ente() As String
  11.         Get
  12.             Return _ente
  13.         End Get
  14.         Set(ByVal value As String)
  15.             _ente = value
  16.         End Set
  17.     End Property
  18.     Public Property detalle() As String
  19.         Get
  20.             Return _detalle
  21.         End Get
  22.         Set(ByVal value As String)
  23.             _detalle = value
  24.         End Set
  25.     End Property
  26.     Public Property mes() As Integer
  27.         Get
  28.             Return _mes
  29.         End Get
  30.         Set(ByVal value As Integer)
  31.             _mes = value
  32.         End Set
  33.     End Property
  34.     Public Property anio() As Integer
  35.         Get
  36.             Return _anio
  37.         End Get
  38.         Set(ByVal value As Integer)
  39.             _anio = value
  40.         End Set
  41.     End Property
  42.     Public Property cantidad() As Integer
  43.         Get
  44.             Return _cantidad
  45.         End Get
  46.         Set(ByVal value As Integer)
  47.             _cantidad = value
  48.         End Set
  49.     End Property
  50.     Public Property fecha() As String
  51.         Get
  52.             Return _fecha
  53.         End Get
  54.         Set(ByVal value As String)
  55.             _fecha = value
  56.         End Set
  57.     End Property
  58.     Public Property usr() As String
  59.         Get
  60.             Return _usr
  61.         End Get
  62.         Set(ByVal value As String)
  63.             _usr = value
  64.         End Set
  65.     End Property
  66.     Public Property id() As Integer
  67.         Get
  68.             Return _id
  69.         End Get
  70.         Set(ByVal value As Integer)
  71.             _id = value
  72.         End Set
  73.     End Property
  74. End Class

Y EL MODO
modo_buscar.vb
Código vb:
Ver original
  1. Imports MySql.Data
  2. Imports MySql.Data.Types
  3. Imports MySql.Data.MySqlClient
  4. Module modo_buscar
  5.  
  6.     'VARIABLES PRIVADAS
  7.    Private _adaptador As New MySqlDataAdapter
  8.  
  9.     'VARIABLES PUBLICAS
  10.    Public _resultados As New DataTable
  11.  
  12.     Public Function Buscar(ByVal datos As clase_datos) As Boolean
  13.         Dim estado As Boolean
  14.         Try
  15.             conex_Global()
  16.             _adaptador.SelectCommand = New MySqlCommand("select * from datos where ente=@ente", _conexion)
  17.             _adaptador.SelectCommand.Parameters.Add("@ente", MySqlDbType.VarChar, 20).Value = datos.ente
  18.             _conexion.Open()
  19.             _adaptador.SelectCommand.Connection = _conexion
  20.             _adaptador.SelectCommand.ExecuteNonQuery()
  21.             _adaptador.Fill(_resultados)
  22.  
  23.             If _resultados.Rows.Count > 0 Then
  24.                 estado = True
  25.             Else
  26.                 estado = False
  27.             End If
  28.  
  29.         Catch ex As MySqlException
  30.             MessageBox.Show(ex.Message, "-")
  31.             estado = False
  32.         Finally
  33.             cerrar()
  34.         End Try
  35.         Return estado
  36.     End Function
  37. End Module

Como hago para que me muestre los datos en un datagrid?
Vi un par de tutos pero no los entiendo.
Gracias.
__________________
Un perro no es perro por ladrar, sino por ser perro...