c# - Visual Studio System.Data.OleDb.OleDbException 错误
问题描述
嗨,伙计们,我目前正在 Visual Studio 中处理表单,我的一个表单称为“添加分配”。但是,每次我启动应用程序并尝试添加分配时,我都会收到一条错误消息,提示“您必须在 'ASSIGNMENT.BusinessID' 字段中输入一个值”。
我认为这是因为在我的分配访问数据表中有一个名为 BusinessID 的列。而且我的代码没有解决 BusinessID 因为我不知道如何通过我的代码自动生成它。这是在“添加作业”表单中添加作业的代码。
private void btnAddAssignment_Click(object sender, EventArgs e)
{
DataRow newAssignmentRow = DC.dtAssignment.NewRow();
if (txtAssignmentDescription.Text == "")
{
MessageBox.Show("One or more fields is blank", "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
try
{
newAssignmentRow["AssignmentDescription"] = txtAssignmentDescription.Text;
newAssignmentRow["AssignmentDate"] = dtpAssignmentDate.Value;
newAssignmentRow["AssignmentFee"] = nudFee.Value;
newAssignmentRow["Status"] = cboStatus.Text;
DC.dtAssignment.Rows.Add(newAssignmentRow);
MessageBox.Show("Employee added successfully", "Success");
DC.UpdateAssignment();
ClearFields();
}
catch (FormatException ex)
{
MessageBox.Show("Please enter a number for Fee", "Error");
}
}
这也在我的 DataController 中。我认为这应该有助于生成一个 ID,但我不确定。 代码 我将非常感谢任何帮助。非常感谢!
解决方案
推荐阅读
- c# - LiteDB 对不同的条目使用相同的 ID
- elasticsearch - 仅返回匹配的数组项而不是 ElasticSearch 中的所有文档值
- python - Pandas 多个 ISO 时间列 to_datetime
- javascript - 你如何在一个js按钮上放置一个onclick
- windows - 使用另一个变量将上下文存储在另一个变量中
- javascript - 使用 Laravel 邮件功能时的 CSS 延迟
- amazon-web-services - AWS SSH 访问密钥生成过程并安装在 EC2 上
- django - 如何从外键字段中获取值?django
- gremlin - 如何在gremlin中使用coalesce和select?
- r - 有没有办法在 fviz_eig 图中添加一个 cum sum?