在此SQL選擇命令中找不到錯誤。數據庫是mySql。選擇命令工作得很好用MS ACCESS數據庫,但:傳遞參數時SQL語句中的錯誤
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:recipesConnectionString %>"
ProviderName="<%$ ConnectionStrings:recipesConnectionString.ProviderName %>"
SelectCommand="SELECT IDrecipe, title FROM recipe WHERE (title LIKE '%' + @IDTextBox1 + '%')">
</asp:SqlDataSource>
上述生成以下錯誤:
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 '+ 'sauce' + '%')' at line 1
嘗試'WHERE(LIKE標題CONCAT( '%',@ IDTextBox1, '%'))',因爲'+'是在MySQL _not_字符串連接。 – Wrikken