You need to sign in to do that
Don't have an account?
please help me.
Error: input Compile Error: Illegal assignment from LIST<Account> to account at line 8 column 3. please tell me the error meaning
public class input {
public account a{get;set;}
public input()
{
id id1 = ApexPages.currentpage().getParameters().get('id');
if(id1<>null)
{
a= [select id,name,industry,phone from account where id = :id1];
}
else
{
a = new account();
}
}
public PageReference save() {
upsert a;
a= new account();
return (new ApexPages.StandardController(a).view());
}
}
<apex:page controller="input">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!a.name}"/>
<apex:inputField value="{!a.phone}"/>
<apex:inputField value="{!a.industry}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
In this line:
you are assigning the list that is returned from the SOQL call to a single account. Something like the following should fix it (and protect you against an id that doesn't exist!)
<p>Error: input Compile Error: Illegal assignment from LIST to LIST at line 8 column 2</p>
It works for me - can you post the updated code.