i want to prevent record insertion when nameTextBox and addressTextBox are null. but it always throws an exception. the exception message is pointed to submitchanges() which is use to insert the record. below is my code
if (nameTextBox.Text != "" &&
addressTextBox.Text != "")
{
_temporaryMember.Nama = nameTextBox.Text;
_temporaryMember.Alamat = addressTextBox.Text;
_temporaryMember.Telp = phoneNbrTextBox.Text;
}
else
{
{
string pesan = "";
if (nameTextBox.Text == "")
pesan += "Kolom Nama harus diisi.\n";
if (addressTextBox.Text == null)
pesan += "Kolom Alamat harus diisi.\n";
MessageBox.Show(pesan, "Maaf..", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
do you know how to fix it? thanks