+ Start a Discussion
ashok dadali 3ashok dadali 3 

DML opearion

hi can anybody write one apex class for  DML operation insert a record into the object and and copy past programme here  
public class InsertRecord 
    sObject rec;
    boolean result = false;
    public boolean addRecord(string objName)
        if(objName == 'Account')
            rec = new Account(name='test');
            insert rec;
            result = true;
        return result;
    public void ClickMe()
        boolean res = addRecord('Account');

Here you can call method ClickMe from visualforce page to create account record. Below will be example VF page:

<apex:page controller="InsertRecord">
        <apex:commandButton action="{!clickme}" value="Create Account"/>