Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking all fields are validated successfully through buttonclick in C#
    primarykey
    data
    text
    <p>In my Windows form I have a <code>Button</code> called Save. When I click on that button, data should be saved to database if all fields in the form are validated successfully. Otherwise, an error message should be displayed.</p> <p>I have tried:</p> <pre><code>private void btnNotesSave_Click(object sender, EventArgs e) { if (this.ValidateChildren(ValidationConstraints.None)) { DataRow dr = ds.Tables[0].NewRow(); dr[0] = txtName.Text; dr[1] = txtPersonResponsible.Text; dr[2] = txtPersonResponsibleIDDetails.Text; dr[3] = txtAlternativePersonResponsible.Text; dr[4] = txtAlternativePersonResponsibleIDDetails.Text; dr[5] = txtCompanyRegNo.Text; dr[6] = txtVatNo.Text; dr[7] = txtPremiseNo.Text; dr[8] = txtStreetName1.Text; dr[9] = txtStreetName2.Text; dr[10] = txtSubUrb.Text; dr[11] = txtCity.Text; dr[12] = txtProvince.Text; dr[13] = txtCountry.Text; dr[14] = txtPinCode.Text; dr[15] = txtPostalPremiseNo.Text; dr[16] = txtPostalStreetName1.Text; dr[17] = txtPostalStreetName2.Text; dr[18] = txtPostalSubUrb.Text; dr[19] = txtPostalCity.Text; dr[20] = txtPostalProvince.Text; dr[21] = txtPostalCountry.Text; dr[22] = txtPostalPinCode.Text; dr[23] = txtTelephone1.Text; dr[24] = txtTelephone2.Text; dr[25] = txtMobile1.Text; dr[26] = txtMobile2.Text; dr[27] = txtFax1.Text; dr[28] = txtFax2.Text; dr[29] = txtEmail1.Text; dr[30] = txtEmail2.Text; dr[31] = txtWebsite.Text; dr[32] = txtWorkingHours.Text; dr[33] = txtAccountHolderName.Text; dr[34] = txtBankName.Text; dr[35] = txtAccountType.Text; dr[36] = txtAccountNumber.Text; dr[37] = txtBranchCode.Text; dr[38] = rtxtBanking.Text; dr[39] = txtCreditLimit.Text; dr[40] = txtStartingDate.Text; dr[41] = txtEndingDate.Text; dr[42] = lstFinance.Text; dr[43] = rtxtFinance.Text; dr[44] = rtxtNotes.Text; ds.Tables[0].Rows.Add(dr); cb = new SqlCommandBuilder(da); da.Update(ds, "CompanyDetails"); MessageBox.Show("data saved to DB"); } else MessageBox.Show("please fill all mandatory fields"); } </code></pre> <p>But this is not working.</p> <p>Thanks in advance!!! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload