Quantcast
Channel: Like en mySql
Viewing all articles
Browse latest Browse all 5

Like en mySql

$
0
0

Hola walox, el problema en esa consulta es que '% + ?nombre +  %'lo toma como un texto entero, no se si me entendes, no toma el valor del parametro, al estar todo comprendido dentro del '' es el texto entero.

Para mySql el @ sirve para especificar que la entrada es un parametro, no con ?.

La respuesta de Leandro me sirvió, usando el CONCAT(...)

Dejo el ejemplo por si a alguien le sirve, salu2

PublicSharedFunction obtenerClientesPorNombre(ByVal xnombre AsString) As List(Of Cliente)Dim clientes As List(Of Cliente) = NothingDim cliente As Cliente = NothingDim sql AsString = String.Empty

        sql = "SELECT id, "& _"nombre "& _"FROM Clientes "& _"WHERE (nombre LIKE CONCAT('%', @nombre, '%'))"

        clientes = New List(Of Cliente)Using connection AsNew MySqlConnection(ConfigurationManager.ConnectionStrings("mySql").ToString())Try
                connection.Open()Using command As MySqlCommand = connection.CreateCommand()
                    command.CommandType = CommandType.Text
                    command.CommandText = sql

                    command.Parameters.AddWithValue("nombre", xnombre)Using reader As MySqlDataReader = command.ExecuteReader()While reader.Read
                            cliente = ClienteDAL.load(reader)
                            clientes.Add(cliente)EndWhileEndUsingEndUsingCatch ex As ExceptionThrow exEndTryEndUsingReturn clientesEndFunction


 


Leo Lequini

Viewing all articles
Browse latest Browse all 5

Trending Articles


Vimeo 10.7.1 by Vimeo.com, Inc.


UPDATE SC IDOL: TWO BECOME ONE


KASAMBAHAY BILL IN THE HOUSE


Girasoles para colorear


Presence Quotes – Positive Quotes


EASY COME, EASY GO


Love with Heart Breaking Quotes


Re:Mutton Pies (lleechef)


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


Vimeo 10.7.0 by Vimeo.com, Inc.


FORECLOSURE OF REAL ESTATE MORTGAGE


FORTUITOUS EVENT


Pokemon para colorear


Sapos para colorear


Smile Quotes


Letting Go Quotes


Love Song lyrics that marks your Heart


RE: Mutton Pies (frankie241)


Hato lada ym dei namar ka jingpyrshah jong U JJM Nichols Roy (Bah Joy) ngin...


Long Distance Relationship Tagalog Love Quotes



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>