C
Claudio111
Guest
Hi all
I have a win form with textboxs and a DataSet and one Datatable (filled by sql database trhu TableAdapter)
Each TextBox binds to datatable column. One of the columns has the Unique Constraint set to True by designer .
By designer I get the Dataset Partial class to handle ColumnChange events like the following code
Partial Public Class TabRegioniDataTable
Private Sub TabRegioniDataTable_ColumnChanging(sender As Object, e As DataColumnChangeEventArgs) Handles Me.ColumnChanging
' If (e.Column.ColumnName = Me.RegioneDesColumn.ColumnName) Then
MessageBox.Show("Column Changed " & sender.ToString & vbCrLf &
"proposed Value " & e.ProposedValue.ToString & vbCrLf &
" row " & e.Row.ToString & vbCrLf &
"Columns " & e.Column.ToString & vbCrLf &
"type " & e.GetType.ToString)
' End If
End Sub
Now if in TextBox I insert a value that already exists in DataTable, the cursor go back to the TextBox avoiding me to go to next textbox since there is the Unique constraints for that column bind to Textbox.
I would like to catch the uniqe constraint error to ive user a friendly message.
Ho to catch this dataset error (I don't need to catch the sql error because I Update database later if there are not errors in the form)
Continue reading...
I have a win form with textboxs and a DataSet and one Datatable (filled by sql database trhu TableAdapter)
Each TextBox binds to datatable column. One of the columns has the Unique Constraint set to True by designer .
By designer I get the Dataset Partial class to handle ColumnChange events like the following code
Partial Public Class TabRegioniDataTable
Private Sub TabRegioniDataTable_ColumnChanging(sender As Object, e As DataColumnChangeEventArgs) Handles Me.ColumnChanging
' If (e.Column.ColumnName = Me.RegioneDesColumn.ColumnName) Then
MessageBox.Show("Column Changed " & sender.ToString & vbCrLf &
"proposed Value " & e.ProposedValue.ToString & vbCrLf &
" row " & e.Row.ToString & vbCrLf &
"Columns " & e.Column.ToString & vbCrLf &
"type " & e.GetType.ToString)
' End If
End Sub
Now if in TextBox I insert a value that already exists in DataTable, the cursor go back to the TextBox avoiding me to go to next textbox since there is the Unique constraints for that column bind to Textbox.
I would like to catch the uniqe constraint error to ive user a friendly message.
Ho to catch this dataset error (I don't need to catch the sql error because I Update database later if there are not errors in the form)
Continue reading...