Public Class Form1
Private ContactsTableBindingSource As Object
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'ContactsTableDataSet.Table' table. You can move, or remove it, as needed.
Me.TableTableAdapter.Fill(Me.ContactsTableDataSet.Table)
If ComboBox1.Text = Nothing Then
Try
ContactsTableBindingSource.AddNew()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If First_NameTextBox.Text = Nothing Then
First_NameTextBox.Text = "unknown"
End If
If Last_NameTextBox.Text = Nothing Then
Last_NameTextBox.Text = "unknown"
End If
If AddressTextBox.Text = Nothing Then
AddressTextBox.Text = "unknown"
End If
If Phone_NumberTextBox.Text = Nothing Then
Phone_NumberTextBox.Text = "unknown"
End If
If Email_AddressTextBox.Text = Nothing Then
Email_AddressTextBox.Text = "unknown"
End If
Try
Me.Validate()
Me.ContactsTableBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.ContactsTableDataSet)
MessageBox.Show("The data has been saved", "Information", MessageBoxButtons.OK)
ContactsTableBindingSource.AddNew()
First_NameTextBox.Select()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
请在代码中建议更正,因为我显示错误"对象变量或Withblock未设置"