+ Start a Discussion

Dynamic SOQL query result


   I would get the values from dynamic soql query. here in detail  

   XmlRD__c queryResult = Database.query('Select \''+field +'\' from XmlRD__c where id = \''+ recordid +'\'');
   String Text = String.valueof(queryResult.field);

   Here the red marking field values getting dynamically changing. i want to get the dynamic field value. but here throwing the issue. How can i get.            

Best Answer chosen by Admin (Salesforce Developers) 

Try following :-

String Text = (String)queryResult.get(field));