title: Data insert error - object reference not set to an instance of an object
body: <pre><code>private void button2_Click(object sender, EventArgs e)
  {
      //    try
      //    {
      DateTime admission = Convert.ToDateTime(dtpadmission.Value);
      DateTime expiry = Convert.ToDateTime(dtpexpirydate.Value);
      DateTime release = Convert.ToDateTime(dtpreleasedate.Value);
      DateTime amount = Convert.ToDateTime(dtpreceiptamount.Value);
      DateTime warrant = Convert.ToDateTime(dtpwarrantdate.Value);
  
      //dLayer.insertadmitcivilprison(admission.ToString(), txtpmsno.Text.ToString(), txtname.Text.ToString(), txtfname.Text.ToString(), cmbgender.SelectedItem.ToString(), txtoccupation.Text, txtvillage.Text, txtdistrict.Text, txtheight.Text, txtphesiogamy.Text, txtage.Text, cmbresidence.SelectedItem.ToString(), txtcaste.Text, txteducation.Text, txtpolicestation.Text, txtcolor.Text, txtidentification.Text, Txtwhichprison.Text, txtwhytransfered.Text, txtsrnoformerprison.Text, txtnamedetainingcreditor.Text, txtamountofclaim.Text, txtsentenceauthority.Text, txtcauseofdetention.Text, txtwarrantno.Text, warrant.ToString(), expiry.ToString(), release.ToString(), txtweightondischarge.Text, txtweightonadmission.Text, txtrealeaseauthority.Text, txtdurationimprisonment.Text, txtdailydietmonety.Text, txtamountreceived.Text, amount.ToString(), txtprivateproperty.Text, txtbalanceleft.Text, txtbalancedisposedoff.Text);
      //MessageBox.Show("Data inserted Successfully");
      SqlHelper.ExecuteNonQuery(dLayer.con, CommandType.Text, "insert into pcms.tbl_prisoner_detail (date_of_admission,pmsno,pname,pfname,sex,last_occupation,address,district,height,phesiogamy,age,residence,caste,education_qualification,police_station,color,identification_mark,previous_prison,transfer_reason,registration_no_pre_prison,reason_for_detention,amount_of_claim,sentencing_authority,reason_for_detention,warrant_no,date_of_warrant,expiry_date_imprisonment,date_of_release,weight_on_discharge,weight_on_admission,authority_of_discharge,imprisionment_duration,daily_diet_allowance_granted,amount_received,date_of_recieve,property_recieved,balance_left,balance_disposed_off) values('" + admission.ToString() + "','" + txtpmsno.Text + "','" + txtname.Text + "','" + txtfname.Text + "','" + cmbgender.SelectedItem.ToString() + "','" + txtoccupation.Text + "','" + txtvillage.Text + "','" + txtdistrict.Text + "','" + txtheight.Text + "','" + txtphesiogamy.Text + "','" + txtage.Text + "','" + cmbresidence.SelectedItem.ToString() + "','" + txtcaste.Text + "','" + txteducation.Text + "','" + txtpolicestation.Text + "','" + txtcolor.Text + "','" + txtidentification.Text + "','" + Txtwhichprison.Text + "','" + txtwhytransfered.Text + "','" + txtsrnoformerprison.Text + "','" + txtnamedetainingcreditor.Text + "','" + txtamountofclaim.Text + "','" + txtsentenceauthority.Text + "','" + txtcauseofdetention.Text + "','" + txtwarrantno.Text + "','" + warrant.ToString() + "','" + expiry.ToString() + "','" + release.ToString() + "','" + txtweightondischarge.Text + "','" + txtweightonadmission.Text + "','" + txtrealeaseauthority.Text + "','" + txtdurationimprisonment.Text + "','" + txtdailydietmonety.Text + "','" + txtamountreceived.Text + "','" + amount.ToString() + "','" + txtprivateproperty.Text + "','" + txtbalanceleft.Text + "','" + txtbalancedisposedoff.Text + "')");
  }
  </code></pre>
  
  <p>Code on data layer:</p>
  
  <pre><code>public void insertadmitcivilprison(string dateofadmission,string pmsno, string prisonername, string prisonerfathername, string gender, string occupation, string village, string district, string height, string phesiogamy, string age, string residence, string caste, string education, string police_station, string color, string identification_mark, string from_which_prison, string why_trasfered, string PMS_in_former_prison, string detaining_creditor, string amount_of_claim, string sentencing_authority, string cause_of_detention, string warrant_no, string warrant_date, string expiry_date_imprisonment, string release_date, string weight_on_discharge, string weight_on_admission, string authority_for_release, string duration_imprisonment, string diet_money, string amount_received, string date_receipt_amount, string private_property, string balance_left, string balance_disposedoff)
  {
      //CallingSystem.SqlHelper.ExecuteNonQuery(con, CommandType.Text, "insert into pcms.tbl_prisoner_detail(pmsno,pname,pfname,pms_no,finger_type,user_status,userid,bal_amount,canteen_bal_amount,reg_date) values('" + pmsno + "','" + prisonername + "','" + prisonerfathername + "','" + pms_no + "','" + finger_type + "','" + user_status + "','" + userid + "','" + bal_amount + "','" + canteen_bal_amount + "','" + reg_date + "')");
      CallingSystem.SqlHelper.ExecuteNonQuery(con, CommandType.Text, "insert into pcms.tbl_prisoner_detail (date_of_admission,pmsno,pname,pfname,sex,last_occupation,address,district,height,phesiogamy,age,residence,caste,education_qualification,police_station,color,identification_mark,previous_prison,transfer_reason,registration_no_pre_prison,reason_for_detention,amount_of_claim,sentencing_authority,reason_for_detention,warrant_no,date_of_warrant,expiry_date_imprisonment,date_of_release,weight_on_discharge,weight_on_admission,authority_of_discharge,imprisionment_duration,daily_diet_allowance_granted,amount_received,date_of_recieve,property_recieved,balance_left,balance_disposed_off) values('" + dateofadmission + "','" + pmsno + "','" + prisonername + "','" + prisonerfathername + "','" + gender + "','" + occupation + "','" + village + "','" + district + "','" + height + "','" + phesiogamy + "','" + age + "','" + residence + "','" + caste + "','" + education + "','" + police_station + "','" + color + "','" + identification_mark + "','" + from_which_prison + "','" + why_trasfered + "','" + PMS_in_former_prison + "','" + detaining_creditor + "','" + amount_of_claim + "','" + sentencing_authority + "','" + cause_of_detention + "','" + warrant_no + "','" + warrant_date + "','" + expiry_date_imprisonment + "','" + release_date + "','" + weight_on_discharge + "','" + weight_on_admission + "','" + authority_for_release + "','" + duration_imprisonment + "','" + diet_money + "','" + amount_received + "','" + date_receipt_amount + "','" + private_property + "','" + balance_left + "','" + balance_disposedoff + "')");
  }
  </code></pre>