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
Deepu2123Deepu2123 

Error on my visualforce page

Hi
Can Anybody please explain the issue, please
List has no rows for assignment to SObject this error is showing when I am clicking on the preview.

Apex class:
public class mycontroller{.

  public string getname() {
     return 'saicharan';
     }  
   public Account getaccount() {
        return [select id, name from account 
                 where id = :ApexPages.currentPage().getParameters().get('id')]; 
      }
}

Visualforce page: 

<apex:page controller="mycontroller">
<apex:pageBlock title="Hello World {!$User.FirstName}!"> This is my New Page for the {!name} my controller. <br/>
 You are viewing the {!account.name} account.
 </apex:pageBlock>
</apex:page>
Alain CabonAlain Cabon
Hi,

Your code is correct but the preview cannot work because you have to put the id in the URL:

http://xxxx.visual.force.com/apex/myVFPpage?id=0010Y000009SvCy

Just view an existing account and add: /apex/myVFPpage?id= in the URL just before the ID.

Regard