Entering information into database with visual studio form

I am encountering a problem when I attempt to enter information into a database that is connected to my visual studio 2012 form. When I start debugging if I enter information into the fields and hit submit, nothing gets entered into my database. If I enter the information again and hit submit, the information then will write to my database. I am not really great at programming, so I used the data sources to link my visual studio form and my database.

This is what my form looks like; data form before entry

This is what my form looks like with data I enter; data form with information

This is what happens when you hit submit; confirmation message

This is the database after hitting submit the first time; db entries after first submission

This is what happens when I enter the information again; db entries after second submission

Any entries after this will enter correctly, and things are great. I am confused as to why information (besides the null entry) wont enter until the second time I click submit. While it "technically works" it's not quite right. Any help on the issue would be much appreciated.

Here is my code for my submit button in my New Customer Form;

namespace WindowsFormsApplication2
{
public partial class frmNewCustomer : Form
{
    public frmNewCustomer()
    {
        InitializeComponent();
    }

    private void btnAddCustomer_Click(object sender, EventArgs e)
    {
        string cstFName;
        string cstLName;
        string cstAddress;
        string cstCity;
        string cstState;
        string cstZip;
        string cstPhone;
        string cstEmail;

        cstFName = cstFNameTxtBox.Text;
        cstLName = cstLNameTxtBox.Text;
        cstAddress = cstAddressTxtBox.Text;
        cstCity = cstCityTxtBox.Text;
        cstState = cstStateTxtBox.Text;
        cstZip = cstZipTxtBox.Text;
        cstPhone = cstPhoneTxtBox.Text;
        cstEmail = cstEmailTxtBox.Text;

        // exception handler for empty fields    
        if (cstFName == "")
        {
            MessageBox.Show("Please enter your first name!");
        }
        else if (cstLName == "")
        {
            MessageBox.Show("Please enter your last name!");
        }
        else if (cstAddress == "")
        {
            MessageBox.Show("Please enter your address!");
        }
        else if (cstCity == "")
        {
            MessageBox.Show("Please enter your city!");
        }
        else if (cstState == "")
        {
            MessageBox.Show("Please enter your state!");
        }
        else if (cstZip == "")
        {
            MessageBox.Show("Please enter your zip!");
        }
        else if (cstPhone == "")
        {
            MessageBox.Show("Please enter your Phone!");
        }
        else if (cstEmail == "")
        {
            MessageBox.Show("Please enter your email!");
        }
        else
        {
            MessageBox.Show("First Name: " + cstFName + " Last Name: " + cstLName + "\r\n" +
                            "Address: " + cstAddress + "\r\n" +
                            "City: " + cstCity + " State: " + cstState + " Zip: " + cstZip + "\r\n" +
                            "Phone: " + cstPhone + " Email: " + cstEmail + "\r\n" + "\r\n" +
                            "Has been added to the database.");
        }

        this.tblCustomersBindingSource.AddNew();
        this.tblCustomersBindingSource.EndEdit();
        this.tblCustomersTableAdapter.Update(this.dataSet1.tblCustomers); // Updating the DB Table
    }

    private void frmNewCustomer_Load(object sender, EventArgs e)
    {
        // TODO: This line of code loads data into the 'dataSet1.tblCustomers' table. You can move, or remove it, as needed.  Loads it into start of form!
        // this.tblCustomersTableAdapter.Fill(this.dataSet1.tblCustomers);

    }
  }
}

I realize my exception handling is janky at best, but this is more about creating a few forms that read and write data to a db. I appreciate any help anyone is able to offer,

Answers


If this weren't winforms (not sure that it matters), the typical flow is this:

Create a connection.  
Write your insert statement.  
Do data validation.  
Submit to database.  
Commit transaction.  

try this:

bool shouldSubmit = false;
     // exception handler for empty fields    
            if (cstFName == "")
            {
                MessageBox.Show("Please enter your first name!");
            }
            else if (cstLName == "")
            {
                MessageBox.Show("Please enter your last name!");
            }
            else if (cstAddress == "")
            {
                MessageBox.Show("Please enter your address!");
            }
            else if (cstCity == "")
            {
                MessageBox.Show("Please enter your city!");
            }
            else if (cstState == "")
            {
                MessageBox.Show("Please enter your state!");
            }
            else if (cstZip == "")
            {
                MessageBox.Show("Please enter your zip!");
            }
            else if (cstPhone == "")
            {
                MessageBox.Show("Please enter your Phone!");
            }
            else if (cstEmail == "")
            {
                MessageBox.Show("Please enter your email!");
            }
            else
            {
                shouldSubmit = true;
                MessageBox.Show("First Name: " + cstFName + " Last Name: " + cstLName + "\r\n" +
                                "Address: " + cstAddress + "\r\n" +
                                "City: " + cstCity + " State: " + cstState + " Zip: " + cstZip + "\r\n" +
                                "Phone: " + cstPhone + " Email: " + cstEmail + "\r\n" + "\r\n" +
                                "Has been added to the database.");
            }

if(shouldSubmit)
{
            this.tblCustomersBindingSource.AddNew();
            this.tblCustomersBindingSource.EndEdit();
            this.tblCustomersTableAdapter.Update(this.dataSet1.tblCustomers); // Updating the DB Table  
}

Need Your Help

How to improve the output of this XOR?

c encryption

I am just trying to make a simple encryption that is obviously not secure at all. Everything is just fine but I am getting unprintable characters such as new line or nul. It becomes problem when de...

In a Visual Studio C++ project with /clr, are its dependencies also compiled to managed code?

visual-studio clr unmanaged managed

To be a bit more clear. If I have a Visual Studio C++ solution that has two projects, say a static library with CLR support turned off, and a second project with CLR support turned on that depends on