- NoNullAllowedExceptionはbtnSave_Clickイベントで処理されました
- SQL 2005には、DealerId、Name、Address、Phonenoの4つの列があります。
- [保存]ボタンをクリックすると、次のエラーが発生します:列'DealerID'はnullを許可しません
エラーメッセージ画像:
public partial class frmDealerForm : Form
{
DataTable t;
DataRow r;
public frmDealerForm()
{
InitializeComponent();
}
private void btnSave_Click(object sender, EventArgs e)
{
t = kalliskaBillingDataSet.Tables["DealerDetail"];
r = t.NewRow();
r[0] = txtdealerID.Text;
r[1] = txtname.Text;
r[2] = txtaddress.Text;
r[3] = txtphoneno.Text;
//Column 'DealerID' does not allow nulls//
t.Rows.Add(r);
dealerDetailTableAdapter.Update(kalliskaBillingDataSet);
txtdealerID.Text = System.Convert.ToString(r[0]);
MessageBox.Show("Data Saved", "DealerDetail", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}