Handling method of error reporting with multiplication sign in SQL statement

Time:2021-9-15

In ADO, we need to use multiplication in SQL statements, but after adding ‘*’, the execution program will always make errors. This is because ‘*’ coincides with the ‘*’ keyword in SQL, so compilation will make errors.

Solution: put the multiplication operation outside the SQL statement, put the result into a variable, and then reference it in the SQL statement

int count = (this.AspNetPager1.CurrentPageIndex-1)*this.AspNetPager1.PageSize;
string sql = " select top "+count+" E_Id from Emp order by E_Id asc";// Custom SQL statements