What is the easiest way to validate textboxes that need to be checked before they go through. I have 2 tables I have to insert my data into as well and that's just for one group, in total I have 3 groups but just a helpful tip towards the one will be fine.
It needs to be checked before it runs so how would I do it before the try/catch block and still just use the one button click.
I have the main table which is 'Person' and then 3 sub tables; 'Student', 'Teacher', 'Administration'.
Not all the textboxes need to be validated. sAdd2.Text and StudentType.Text.
My normal code is
TypeScript
private void sNew_Click(object sender, EventArgs e)
{
try
{
personTableAdapter.Insert(sFirstName.Text, sSurname.Text,
Convert.ToDateTime(sDoB.Text), sPhone.Text, sAdd1.Text, sAdd2.Text,
sSuburb.Text, sState.Text, sPostcode.Text, StudentType.Text);
studentTableAdapter.Insert(Convert.ToInt32(sSID.Text),
Convert.ToDateTime(sSDate.Text), sQCode.Text);
MessageBox.Show(sFirstName.Text + " " + sSurname.Text + " has been added");
this.personTableAdapter.Fill(this._30002195DataSet.Person);
this.studentTableAdapter.Fill(this._30002195DataSet.Student);
this.Hide();
Admin f1 = new Admin();
f1.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}Code
I have tried to use errorProvider and it doesn't stop to check, it just runs and checks and still submits into the database.
Answers
Know the answer? Post it. Somebody with the same question will find it here.