You need to sign in to do that
Don't have an account?
samruddhi pode
Getting visualforce page error as List has no rows for assignment to SObject An unexpected error has occurred.
Getting visualforce page error as List has no rows for assignment to SObject. An unexpected error has occurred. Your development organization has been notified.
Here is my page controller.
Controller-
public class MyFirstController {
private final Account account;
public MyFirstController () {
account = [SELECT Id, Name, Site FROM Account
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
}
public Account getAccount() {
return account;
}
public PageReference save() {
update account;
return null;
}
}
Here is my page controller.
Controller-
public class MyFirstController {
private final Account account;
public MyFirstController () {
account = [SELECT Id, Name, Site FROM Account
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
}
public Account getAccount() {
return account;
}
public PageReference save() {
update account;
return null;
}
}
Its always a best practive to use List<Account> at place of Account.
you got this error becasue your query not getting any single record
Soql always return List so use below code for handle it Thanks
let me inform if it helps you And Mark it best answer so it make proper solution for others in future :)