+ Start a Discussion
sk kumarsk kumar 

showing error while writing code in visual force pages..!!!

Here below my code logic is when i search perticular name in account it will search the respective  field name & phone number from account.....but while running the code in visulaforce i got error like...:

 Error: controller1 Compile Error: Illegal assignment from LIST<Account> to LIST<Account> at line 8 column 10

so anyone help me in this regard.....

                                                               Thanx in advance..:)

 

----------------------------------------------------------controller..------------------------------------------------------------------------------

public with sharing class Controller2

 {

    public string acName {get; set;}
     public List<Account> acc {get;set;}

        public List<Account> search()

     {
             acc= new list<Account>();
             acc=[select name, phone, rating from account where name =: acName];
              return null;
         }
  } 

 

 

============ vf page=======================================

 

 

<apex:page controller="Controller2">
        <apex:form >
                  <apex:pageblock title="Account info">
                                      Account Name: <apex:inputtext value="{!acName}"/>
                                               <apex:pageblockSection >
                                                        <apex:commandButton value="Search" action="{!search}"/>
                                                            <apex:outputPanel >
                                                       <apex:pageblocktable value="{!acc}" var="a">
                                             <apex:column value="{!a.Name}"/>
                                      <apex:column value="{!a.phone}"/>
                                </apex:pageblocktable>
                        </apex:outputPanel>
                </apex:pageblockSection>
          </apex:pageblock>
     </apex:form>
</apex:page>

bob_buzzardbob_buzzard

When I hit this error message, it usually means that I have created a class called Account that is conflicting with the sobject name of Account.  If that is the case then renaming the Account class to AccountObj or similar will fix it.

RockzzRockzz

Hi Kumar..

 

In your organization somewhere you have created a class named "Account". Thats why the compiler is not able to understand that it is standard Object Account or the class created by you. Please rename your class, it will work.

 

Thanks,

Cool Sfdc