Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/02/2013, 00:33
yankovengeance
 
Fecha de Ingreso: febrero-2013
Mensajes: 6
Antigüedad: 11 años, 2 meses
Puntos: 0
Pregunta Filtrar datagridview

Hola tengo un problema para buscar datos.

Tengo una Tabla --> DATOS en SQL SERVER

nombre ------ apellido ----- fecha nacimiento -- hora

saul gonzales 2-2-2013 14:00

franco tapia 3-3-2013 8:00

roberto saez 4-4-2013 3:00

4 Textbox para cada campo TEXTBOXNOMBRE TEXTBOXAPELLIDO TEXTBOXFECHA TEXTBOX HORA

un datagridview y un boton "BUSCAR"

hice un storedProcedure

------------------------------------------------------

Create Store Procedure Buscar

(@nombre varchar @apellido varchar @fecha datetime @hora time)

as

select * from Datos where nombre =@nombre and apellido = @apelllido and fecha =@fecha and hora= @hora

------------------------------------------------------------

Yo quiero que en mi formulario cuando yo presione "Buscar" recorra los 4 textbox de los campos y muestre en el datagridview. Noquiero filtrar un concepto ala vez sino que filtre varios conceptos
es decir

si escribo en mi TEXTBOXNOMBRE " franco " Y EL TEXTBOXAPELLIDO "saez" y presiono Buscar

muestre las filas que tienen dichos datos

franco tapia 3-3-2013 8:00

roberto saez 4-4-2013 3:00

ESTA ES LA FORMA EN LA QUE TRABAJO MI CODIGO
-------------------------------------------------------------------
Sub buscarnombreevento()
Dim con As New SqlConnection("Server=.\SQLEXPRESS;Database=Regist roEvento;Trusted_Connection=True")
con.Open()
Dim dt As New DataTable
Dim da As New SqlDataAdapter("Buscar", con)
da.SelectCommand.CommandType = CommandType.StoredProcedure
da.SelectCommand.Parameters.AddWithValue("@nombre" , Me.TEXTBOXNOMBRE.Text)
da.SelectCommand.Parameters.AddWithValue("@apellid o", Me.TEXTBOXAPELLIDO.Text)
da.SelectCommand.Parameters.AddWithValue("@fechar" , Convert.todatetime(Me.TEXTBOXFECHA.Text))
da.SelectCommand.Parameters.AddWithValue("@hora", Convert.ToDateTime(Me.TEXTBOXHORA.Text))
da.Fill(dt)
Me.DataGridView1.DataSource = dt
con.Close()
limpiar()
End Sub
----------------------------------
Private Sub BOTONBUSCAREVENTO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BOTONBUSCAREVENTO.Click
buscarnombreevento()
End Sub
--------------------------
SI TENGO ERROR EN EL PROCEDURE O EN MI COD.DE VB PODRIAN AYUDARME
LES AGRADECERIA INFINITAMENETE SI AYUDARAN.SALUDOS