-1

I want to save a query as a string with "variable-name" in a file as -

SELECT Id FROM Object WHERE name = "+ VARIABLE_NAME + "

and want to execute query like -

public void executeQuery(String VARIABLE_NAME)
 {
   String query = ReadQuery(); // some method which reads queryfrom file.

   ExecuteQuery(query );   // value of VARIABLE_NAME should be included from parameter  

  }

I want to variable Value should be included from parameter. I can not use it like this -

command.Parameters.AddWithValue("@VARIABLE_NAME", VARIABLE_NAME);

Please provide me a solution.

Thanks in advance.

Note : This is SOQL query, not SQL query.

1 Answers1

0

I assume your problem was not surrounding the parameter string with ' '.

SOQL = "select x, y, z from Document where y='" + SOME_PARAMETER + "';";

However, this is highly vulnerable to SQL injection.

Moka
  • 262
  • 1
  • 9