GRACIAS ALIAGAAAAAAAAA
me alegria es inmesa, estaba haciendo una funcion pero
no me funciona donde le paso dos parametros pero
pienso que es mejor de esta forma, le mando la funcion
a ver si serve a alguien chao y muchas gracias.
Function Buscar(ByVal paramTabla As String, ByVal
paramBusca As String) As Integer
Dim DS As DataSet
Dim connectionString = "File
name=c:\Helpdesk.udl"
Dim Connection As OleDbConnection = New
OleDbConnection(connectionString)
Dim Command As OleDbDataAdapter
Dim SelectCommand As String = "SELECT
RequisicionID, Asunto, Producto, Descripcion, Fecha
Usuaio " & _
"FROM
requisicion WHERE '" & paramTabla & "' LIKE '" & _
paramBusca & "'
and estado = 0"
Command = New OleDbDataAdapter(SelectCommand,
Connection)
DS = New DataSet()
Command.Fill(DS, "requisicion")
MyDataGrid.DataSource
DS.Tables("requisicion").DefaultView
MyDataGrid.DataBind()
Connection.Close()
End Function
--- ALIAGA CESAR <CALIAGA@s...> escribió: >
Prueba con esto
>
> Dim SelectCommand As String
> Dim Condcion as String
> SelectCommand = "SELECT RequisicionID, Asunto,
> Producto,
> Descripcion, Fecha Usuaio " & _
> "FROM requisicion WHERE estado = 0 "
> select case RadioButtonList1.SelectedIndex
> case 0
> Condcion =" AND Asunto LIKE " & txtBusca.Text &
> "%"
>
> case 1
> Condcion =" AND Usuario LIKE " & txtBusca.Text &
> "%"
> case 2
> Condcion =" AND Producto LIKE " & txtBusca.Text
> &
> "%"
> case 3
> Condcion =" AND Descripcion LIKE " &
> txtBusca.Text
> & "%"
> end select
> SelectCommand =SelectCommand & Condcion
>
> Dim DS As DataSet
> Dim MyConnection As SqlConnection
> Dim MyCommand As SqlDataAdapter
> MyConnection = New SqlConnection("server='SQL2000';
> user id='sa';
> password=''; Database='Helpdesk'")
> MyCommand = New SqlDataAdapter(SelectCommand,
> MyConnection)
>
> DS = New DataSet()
> MyCommand.Fill(DS, "requisicion")
> MyDataGrid.DataSource
> DS.Tables("requisicion").DefaultView
>
> MyDataGrid.DataBind()
> MyConnection.Close()
> Listo
>
>
> > -----Mensaje original-----
> > De: abiezer matos [SMTP:negrabichuela@y...]
> > Enviado el: Martes, 29 de Octubre de 2002 02:19
> p.m.
> > Para: ASP.Net en Español
> > Asunto: [aspx_espanol] reutilizacion de codigo
> >
> >
> >
> > Hola a todos,Estoy haciendo una búsqueda, utilizo
> un radio botón para
> > saber por que campo buscar pero pienso que es
> demasiado códigoPor favor si
> > alguien me puede ayudar a analizar como ahorrarme
> este código con una
> > función se lo agradeceré.Este es el código:
> > Private Sub Button1_Click(ByVal sender As
> System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > If RadioButtonList1.SelectedIndex = 0 Then
>
> > Dim DS As DataSet
> > Dim MyConnection As SqlConnection
> > Dim MyCommand As SqlDataAdapter
> > Dim SelectCommand As String = "SELECT
> RequisicionID, Asunto,
> > Producto, Descripcion, Fecha Usuaio " & _
> > "FROM requisicion WHERE Asunto LIKE @Asunto and
> estado = 0"
> > MyConnection = New
> SqlConnection("server='SQL2000'; user id='sa';
> > password=''; Database='Helpdesk'")
> > MyCommand = New SqlDataAdapter(SelectCommand,
> MyConnection)
> >
> > MyCommand.SelectCommand.Parameters.Add(New
> SqlParameter("@Asunto",
> > SqlDbType.NVarChar, 10))
> >
> MyCommand.SelectCommand.Parameters("@Asunto").Value
> = txtBusca.Text & "%"
> >
> > DS = New DataSet()
> > MyCommand.Fill(DS, "requisicion")
> > MyDataGrid.DataSource
> DS.Tables("requisicion").DefaultView
> >
> > MyDataGrid.DataBind()
> > MyConnection.Close()
> > End If
> > If RadioButtonList1.SelectedIndex = 1 Then
>
> > Dim DS As DataSet
> > Dim MyConnection As SqlConnection
> > Dim MyCommand As SqlDataAdapter
> > Dim SelectCommand As String = "SELECT
> RequisicionID, Asunto, Producto,
> > Descripcion, Fecha Usuaio " & _
> > "FROM requisicion WHERE Usuario LIKE @Usuario and
> estado = 0"
> > MyConnection = New
> SqlConnection("server='SQL2000'; user id='sa';
> > password=''; Database='Helpdesk'")
> > MyCommand = New SqlDataAdapter(SelectCommand,
> MyConnection)
> > MyCommand.SelectCommand.Parameters.Add(New
> SqlParameter("@Usuario",
> > SqlDbType.NVarChar, 10))
> >
> MyCommand.SelectCommand.Parameters("@Usuario").Value
> = txtBusca.Text & "%"
> >
> > DS = New DataSet()
> > MyCommand.Fill(DS, "requisicion")
> > MyDataGrid.DataSource
> DS.Tables("requisicion").DefaultView
> > MyDataGrid.DataBind()
> > MyConnection.Close()
> > End If
> > If RadioButtonList1.SelectedIndex = 2 Then
>
> > Dim DS As DataSet
> > Dim MyConnection As SqlConnection
> > Dim MyCommand As SqlDataAdapter
> > Dim SelectCommand As String = "SELECT
> RequisicionID, Asunto, Producto,
> > Descripcion, Fecha Usuaio " & _
> > "FROM requisicion WHERE Producto LIKE @Producto
> and estado = 0"
> >
> > MyConnection = New
> SqlConnection("server='SQL2000'; user id='sa';
> > password=''; Database='Helpdesk'")
> > MyCommand = New SqlDataAdapter(SelectCommand,
> MyConnection)
> > MyCommand.SelectCommand.Parameters.Add(New
> SqlParameter("@Producto",
> > SqlDbType.NVarChar, 10))
> >
>
MyCommand.SelectCommand.Parameters("@Producto").Value
> = txtBusca.Text &
> > "%" DS = New DataSet()
> MyCommand.Fill(DS,
> > "requisicion")
> > MyDataGrid.DataSource
> DS.Tables("requisicion").DefaultView
> > MyDataGrid.DataBind()
> > MyConnection.Close()
> > End If
> > If RadioButtonList1.SelectedIndex = 3 Then
>
> > Dim DS As DataSet
> > Dim MyConnection As SqlConnection
> > Dim MyCommand As SqlDataAdapter
> > Dim SelectCommand As String = "SELECT
> RequisicionID, Asunto, Producto,
> > Descripcion, Fecha Usuaio " & _
> > "FROM requisicion WHERE Descripcion LIKE @Descrip
> and estado = 0"
> >
> > MyConnection = New
> SqlConnection("server='SQL2000'; user id='sa';
> > password=''; Database='Helpdesk'")
> > MyCommand = New SqlDataAdapter(SelectCommand,
> MyConnection)
> > MyCommand.SelectCommand.Parameters.Add(New
> SqlParameter("@Descrip",
> > SqlDbType.NVarChar, 10))
> >
> MyCommand.SelectCommand.Parameters("@Descrip").Value
> = txtBusca.Text & "%"
> >
> > DS = New DataSet()
> > MyCommand.Fill(DS, "requisicion")
> > MyDataGrid.DataSource
> DS.Tables("requisicion").DefaultView
> > MyDataGrid.DataBind()
> > MyConnection.Close()
> > End If
> > End Sub
> > Abiezer MatosDep. DesarrolloExt. 2265
> >
> >
> > ---------------------------------
> > Do You Yahoo!?
> > Todo lo que quieres saber de Estados Unidos,
> América Latina y el resto del
> > Mundo.
> > Visíta Yahoo! Noticias.
> >
> >
> > ---
> > Usted está suscrito a aspx_espanol como:
> > caliaga@s...
> > Para darse de baja, envíe un mensaje en blanco a
>
=== message truncated ===
_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com