Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

DataGrid Input Validation

$
0
0
I am having trouble getting an error message to appear when a user inputs invalid information into a cell into the datagridview.

 Private Sub btnUpdate_Click(sender As System.Object, e As System.EventArgs) Handles btnUpdate.Click
        'Saves and updates any changes made to the database
        Me.Validate()
        If (Me.CustomerTableAdapter.Fill(Me.Aurora2DataSet.Tables("Customer"))) Then

            DataGridView1.DataSource = Me.Aurora2DataSet.Tables("Customer")

            MessageBox.Show("New Customer Added")
        Else
            MessageBox.Show("Invalid Input")
        End If
        Me.Aurora2DataSet.AcceptChanges()


When I inserted break points I noticed that even though I inputted invalid information it would display the first message box and skip over the else statement and move down to the end if. Even though it displays the wrong message box none of the changes are committed back to the database.

My question is what would be causing it to display the first messagebox and skip over the else statement when invalid information is submitted?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>