C# - Using OleDbParameter on table name
问题 I want to protect my app from SQL injection. I want to use OleDbParameter in a SQL query for the table name ({1}). The problem is that it doesn't work (error in FROM or something like that). I can pass the OleDbParameter in {3} thought. Example: IDbCommand cmd = m_oConnection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = String.Format("SELECT {0} FROM {1} WHERE {2}={3}", "ParentID", "?", sWhere, "?" ); cmd.Parameters.Add(new OleDbParameter("@sTable", sTable)); cmd