+ Start a Discussion
sampath pallisampath palli 

How to display records in vf page dynamically using soql

Hi 

I have an requirement that i need to display the records in vf page for example i forget my password i need to retrive my password by using mail id which are existed in custom object,If i entered the email id if this mail id exists it retrives the username and password, else it fires wrror message

Thanks in Advance
Best Answer chosen by sampath palli
Amit Chaudhary 8Amit Chaudhary 8
Try code like  below
String UserName;
String password;

List<Registartion__c> lstReg = [ select UserName__c,Password__c from Registartion__c where email__C = :emailID ];
if(lstReg.size() > 0 )
{
	 UserName = lstReg[0].UserName__c; 
	 password = lstReg[0].Password__c; 
}
else
{
	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Invalid Password'));
	return null;
}
Please change API name according to your org

 

All Answers

Amit Chaudhary 8Amit Chaudhary 8
Try code like  below
String UserName;
String password;

List<Registartion__c> lstReg = [ select UserName__c,Password__c from Registartion__c where email__C = :emailID ];
if(lstReg.size() > 0 )
{
	 UserName = lstReg[0].UserName__c; 
	 password = lstReg[0].Password__c; 
}
else
{
	ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Invalid Password'));
	return null;
}
Please change API name according to your org

 
This was selected as the best answer
sampath pallisampath palli
Hi Amit

Thank u for ur reply i solved my problem 
Can u please suggest me any tips in coding and Any senairos for better practices it's helps me a lot

Thanks in Advance 
sampath pallisampath palli
Thank u Amit