G
Guest
Hi, I'm having problems to get the value of a Querystring into the
SelectCommand of a SQLDataSource, here's my code:
----------------------------------------------
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT cedula,nombre,tipo FROM clientes WHERE nombre LIKE '%'
+ @nombre + '%'">
<SelectParameters>
<asp:QueryStringParameter Name="nombre"
QueryStringField="nombre" type="string" DefaultValue=""/>
</SelectParameters>
</asp:SqlDataSource>
-----------------------------------------------
Here is the URL that call that code....
http://localhost:8103/MySQL_Test/default2.aspx?nombre=daniel
------------------------------------------------
The SelectCommand is not working right, is like the @nombre weren't
returning any value even if I set a default value
I have tried this commands with no result...
-SELECT cedula,nombre,tipo FROM clientes WHERE nombre LIKE '%' + @nombre + '%'
-SELECT cedula,nombre,tipo FROM clientes WHERE nombre LIKE '%' & @nombre & '%'
-SELECT cedula,nombre,tipo FROM clientes WHERE nombre=@nombre
If I set the querystring value directly into the SelectCommand the query
return the expected result:
-SELECT cedula,nombre,tipo FROM clientes WHERE nombre LIKE '%daniel%'
What's wrong with my code?
SelectCommand of a SQLDataSource, here's my code:
----------------------------------------------
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT cedula,nombre,tipo FROM clientes WHERE nombre LIKE '%'
+ @nombre + '%'">
<SelectParameters>
<asp:QueryStringParameter Name="nombre"
QueryStringField="nombre" type="string" DefaultValue=""/>
</SelectParameters>
</asp:SqlDataSource>
-----------------------------------------------
Here is the URL that call that code....
http://localhost:8103/MySQL_Test/default2.aspx?nombre=daniel
------------------------------------------------
The SelectCommand is not working right, is like the @nombre weren't
returning any value even if I set a default value
I have tried this commands with no result...
-SELECT cedula,nombre,tipo FROM clientes WHERE nombre LIKE '%' + @nombre + '%'
-SELECT cedula,nombre,tipo FROM clientes WHERE nombre LIKE '%' & @nombre & '%'
-SELECT cedula,nombre,tipo FROM clientes WHERE nombre=@nombre
If I set the querystring value directly into the SelectCommand the query
return the expected result:
-SELECT cedula,nombre,tipo FROM clientes WHERE nombre LIKE '%daniel%'
What's wrong with my code?