• Sasha Ts
  • NEWBIE
  • 5 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 5
    Replies
Hi all,
quite easy question about Database.query method. I'm learning SF with trailhead.salesforce.com and I'm getting pretty strange error here. I'm using developer edition of SF so should be not problems with some code limits or restrictions here I hope.

https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/visualforce_fundamentals/units/visualforce_custom_controllers
 
public class ContactsListController {

    private String sortOrder = 'LastName';
    
    public List<Contact> getContacts() {
        
        List<Contact> results = Database.query(
            'SELECT Id, FirstName, LastName, Title, Email ' +
            'FROM Contact ' +
            'ORDER BY ' + sortOrder + ' ASC ' +
            'LIMIT 10'
        );
        return results;
    }

}

Error: Method does not exist or incorrect signature: void query(String) from the type Database

User-added image
Hi all,
quite easy question about Database.query method. I'm learning SF with trailhead.salesforce.com and I'm getting pretty strange error here. I'm using developer edition of SF so should be not problems with some code limits or restrictions here I hope.

https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/visualforce_fundamentals/units/visualforce_custom_controllers
 
public class ContactsListController {

    private String sortOrder = 'LastName';
    
    public List<Contact> getContacts() {
        
        List<Contact> results = Database.query(
            'SELECT Id, FirstName, LastName, Title, Email ' +
            'FROM Contact ' +
            'ORDER BY ' + sortOrder + ' ASC ' +
            'LIMIT 10'
        );
        return results;
    }

}

Error: Method does not exist or incorrect signature: void query(String) from the type Database

User-added image