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
Radhika MRadhika M 

line 1, column 1: Illegal assignment from LIST to LIST

list<account> lst=[select id ,name from account  limit 10];

 

how can I get solution for this problem.Every time when i make a query on Account ,it gives an error like  "illegal assignment from LIST to LIST". how can i remove this problem...........?

 
bob_buzzardbob_buzzard

Do you have a custom class named 'Account'?  If so, the compiler will assume that List<Account> is a list of your custom class, and assigning a list of sobject Accounts to that will be treated as an error.

Radhika MRadhika M
Yes I have.If we write class name as object name then i will get this type of problem on every object.Is there any alternate way to rectify this type problem....? Thanks for your suggestion.
bob_buzzardbob_buzzard

You can use the System prefix to identify the sobject account, e.g.

 

list<System.account> lst=[select id ,name from account  limit 10];

 

Personally I'd change the name of the custom account class, as I think it causes confusion going forward.

 

Radhika MRadhika M
HI,how to query records let us say from 6 to 10 like that.........?
bob_buzzardbob_buzzard

You'd need to use the OFFSET feature: 

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_offset.htm

 

list<System.account> lst=[select id ,name from account  limit 5 offset 5];