function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
padmapadma 

System.QueryException: List has more than 1 row for assignment to SObject

 Hi,
Below is my error  when this error will be cmng my page
System.QueryException: List has more than 1 row for assignment to SObject 

Thanks,
padma
Dushyant SonwarDushyant Sonwar
You may be using a object to store list of record.
what you may be doing
------------------------------------------------
contact conlist = [select name from contact];
------------------------------------
and what you have to do
list<contact>conlist=[select name from contact];
SF AdminSF Admin
Hi 

Your SOQL query is returning more than 1 record and you are storing the result in single object. 
u need list of sobject to store the result

You may be doing this:

public Account getaccount() {
      return [select id, name from Account '];
}

what you should do:

public List<Account> getaccount() {
        return [select id, name from Account ];
}

Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
Regards.