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
sri divyasri divya 

hi every one i am new to sfdc i need help i am trying to insert records through vf page in my custom sobject there is no error in my prog its showing but i am not able to insert the record

this is my vf page

<apex:page showHeader="false" sidebar="false"  controller="bankform1">
  <apex:form >
  <apex:commandButton value="save and new" action="{!savenew}"/>
  <apex:commandButton value="cancel" action="{!cancel}"/>
  <apex:commandButton value="dipaly" action="{!display}"/>
  <apex:sectionHeader title="bank" subtitle="bank form"/>
  
  <apex:pageBlock title="personal info">
  <apex:pageBlockSection title="bankform1">
  <apex:pageBlockSectionItem >
  <apex:outputLabel >account holder Name</apex:outputLabel>
  <apex:inputText value="{!c_Name}"/>
  </apex:pageBlockSectionItem><br/>
  
     
  
  </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>




and this is my controller


public class bankform1 {

    public String c_Name { get; set; }

    public PageReference display() {
        return null;
    }


    public PageReference cancel() {
        return null;
    }


    public PageReference savenew() {
        return null;
    }

    public PageReference save()
    
    {
        bankform1__c obj = new bankform1__c();
        obj.name=c_Name;
        insert obj;
        return null;
}
}
SandhyaSandhya (Salesforce Developers) 
Hi,

Try below code
 
​public  class bankform1
{ 
public bankform1__c obj{get; set;} 
public bankform1(){
 obj = new bankform1__c(); 
} 
public void save()
{ 
insert obj; 
} 
}

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
 
Best Regards
Sandhya
 
sri divyasri divya
this is the error that i am facing
Error: bankform1 Compile Error: Unexpected token 'bankform1__c'. at line 1 column 8
sri divyasri divya
thanks for the replay but its notworking
 
Manj_SFDCManj_SFDC
Hi Vidya,
please check the API name of bankform1__c and use it in the code
Gaurish Gopal GoelGaurish Gopal Goel
Hi, Please put the PageMessages in the VF page and then you will get the error message:
<apex:page showHeader="false" sidebar="false"  controller="bankform1">
<apex:pageMessages/>
  <apex:form >
  <apex:commandButton value="save and new" action="{!savenew}"/>
  <apex:commandButton value="cancel" action="{!cancel}"/>
  <apex:commandButton value="dipaly" action="{!display}"/>
  <apex:sectionHeader title="bank" subtitle="bank form"/>
  
  <apex:pageBlock title="personal info">
  <apex:pageBlockSection title="bankform1">
  <apex:pageBlockSectionItem >
  <apex:outputLabel >account holder Name</apex:outputLabel>
  <apex:inputText value="{!c_Name}"/>
  </apex:pageBlockSectionItem><br/>
  
     
  
  </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>