< asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="< %$ ConnectionStrings:MySqlConnection %>" ProviderName="< %$ ConnectionStrings:MySqlConnection.ProviderName %>" SelectCommand="SELECT * FROM kpi_excessdeltavalues WHERE customer = ? "> < SelectParameters> < asp:ControlParameter ControlID="txtCustomer" Name="Customer" PropertyName="Text" Type="String" /> < /SelectParameters> < /asp:SqlDataSource>I've changed the WHERE field to point to both character and numeric fields and it worked without having to do any type conversion.
SelectCommand="SELECT * FROM myTable WHERE (myField LIKE '%' + ? + '%')">
I put a 't' in the textbox but got the following errorERROR [23000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.18-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '+ 't' + '%')' at line 1 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.Odbc.OdbcException: ERROR [23000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.18-nt] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '+ 't' + '%')' at line 1I couldn't find any way to get the % into the SelectCommand without generating an error.
SelectCommand="SELECT * FROM myTable WHERE (myField LIKE ?)"> < SelectParameters> < asp:ControlParameter ControlID="txtInvisible" Name="myField" PropertyName="Text" Type="String" /> < /SelectParameters> Protected Sub txtCustomer_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) txtInvisible.Text = txtCustomer.Text & "%" End SubThis feels like a kluldge to me. Is there a better way of doing this?