简体   繁体   中英

Fix the exception System.Data.SqlClient.SqlException: 'Incorrect syntax near '='.'

When I run the ide show the following exception

System.Data.SqlClient.SqlException: 'Incorrect syntax near '='.'

string query = "SELECT * FROM lwpos_categories  WHERE parent_id=" + ddlCategory.SelectedValue;

Probably ddlCategory.SelectedValue is empty. The following can fix this exception (and I recommend using SqlParameters ).

string query = "SELECT * FROM lwpos_categories  WHERE parent_id= '" + ddlCategory.SelectedValue + "'";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM