How do I protect this function from SQL injection?

前端 未结 11 1191
独厮守ぢ
独厮守ぢ 2020-12-16 18:47
public static bool TruncateTable(string dbAlias, string tableName)
{
    string sqlStatement = string.Format(\"TRUNCATE TABLE {0}\", tableName);
    return ExecuteNo         


        
11条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 18:55

    Have a look at this link

    Does this code prevent SQL injection?

    Remove the unwanted from the tableName string.

    I do not think you can use param query for a table name.

提交回复
热议问题