Hola, espero anden bien....
TENGO
EL FORMULARIO:
form_Buscar.vb
Código vb:
Ver originalImports MySql.Data
Imports MySql.Data.Types
Imports MySql.Data.MySqlClient
Public Class form_Buscar
Private Sub form_Resultados_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim datos As New clase_datos
datos.ente = TxtEnte.Text()
datos.mes = Val(TxtMes.Text())
datos.anio = Val(TxtAnio.Text())
datos.detalle = TxtDetalle.Text()
If Buscar(datos) Then
MsgBox("ENCONTRAMOS ALGO " & _resultados.ToString)
' Me.Hide()
'form_Resultados.Show()
End If
End Sub
End Class
LA CLASE:
class_datos.vb
Código vb:
Ver originalPublic Class clase_datos
Private _id As Integer
Private _ente As String
Private _detalle As String
Private _mes As Integer
Private _anio As Integer
Private _cantidad As Integer
Private _fecha As String
Private _usr As String
Public Property ente() As String
Get
Return _ente
End Get
Set(ByVal value As String)
_ente = value
End Set
End Property
Public Property detalle() As String
Get
Return _detalle
End Get
Set(ByVal value As String)
_detalle = value
End Set
End Property
Public Property mes() As Integer
Get
Return _mes
End Get
Set(ByVal value As Integer)
_mes = value
End Set
End Property
Public Property anio() As Integer
Get
Return _anio
End Get
Set(ByVal value As Integer)
_anio = value
End Set
End Property
Public Property cantidad() As Integer
Get
Return _cantidad
End Get
Set(ByVal value As Integer)
_cantidad = value
End Set
End Property
Public Property fecha() As String
Get
Return _fecha
End Get
Set(ByVal value As String)
_fecha = value
End Set
End Property
Public Property usr() As String
Get
Return _usr
End Get
Set(ByVal value As String)
_usr = value
End Set
End Property
Public Property id() As Integer
Get
Return _id
End Get
Set(ByVal value As Integer)
_id = value
End Set
End Property
End Class
Y EL MODO
modo_buscar.vb
Código vb:
Ver originalImports MySql.Data
Imports MySql.Data.Types
Imports MySql.Data.MySqlClient
Module modo_buscar
'VARIABLES PRIVADAS
Private _adaptador As New MySqlDataAdapter
'VARIABLES PUBLICAS
Public _resultados As New DataTable
Public Function Buscar(ByVal datos As clase_datos) As Boolean
Dim estado As Boolean
Try
conex_Global()
_adaptador.SelectCommand = New MySqlCommand("select * from datos where ente=@ente", _conexion)
_adaptador.SelectCommand.Parameters.Add("@ente", MySqlDbType.VarChar, 20).Value = datos.ente
_conexion.Open()
_adaptador.SelectCommand.Connection = _conexion
_adaptador.SelectCommand.ExecuteNonQuery()
_adaptador.Fill(_resultados)
If _resultados.Rows.Count > 0 Then
estado = True
Else
estado = False
End If
Catch ex As MySqlException
MessageBox.Show(ex.Message, "-")
estado = False
Finally
cerrar()
End Try
Return estado
End Function
End Module
Como hago para que me muestre los datos en un datagrid?
Vi un par de tutos pero no los entiendo.
Gracias.