How to connect with Database using Param in Lightning Component

By | November 13, 2019

Hi, Here we have shown, how to connect to Apex database with param in Lightning component and displayed the data.

Apex Controller : ConnectionWithDatabaseUsingParam

public class ConnectionWithDatabaseUsingParam{
    public static string combine(string apexfname,string apexlname){
        string namer =  apexfname +' '+ apexlname;
        return namer;

Lightning Component : Basic6

<aura:component controller="ConnectionWithDatabaseUsingParam">
    <aura:attribute name="myname" type="string"/>
    <lightning:input label="Enter First Name" aura:id="fnameid"/>
    <lightning:input label="Enter Last Name" aura:id="lnameid"/>
    <Lightning:button label="Click" onclick="{!c.FullName}"/>
        NAME : {!v.myname}

Controller Js

    FullName : function(component, event, helper) {
        var fname=component.find("fnameid").get('v.value');
        var lname=component.find("lnameid").get('v.value');
        var action=component.get('c.combine');
            var state=response.getState();
            if(state === 'SUCCESS'){
                var result = response.getReturnValue();


<aura:application extends="force:slds" >
    <c:Basic6 />


Enter first Name & last Name then click on button you will see the entered data below.

Leave a Reply

Your email address will not be published. Required fields are marked *