这里非常简单,因为我对编码C#非常陌生。正如您所提供的代码所示,我试图解决错误,我在屏幕截图中显示了接收信息。当我尝试更新访问数据库中保存的当前信息时,就会发生这种情况。 正如我所说,可能只是一个,但我无法看到错误
private void btnSchedule_Click(object sender, EventArgs e)
{
try
{
connection.Open();
OleDbCommand command = new OleDbCommand();
command.Connection = connection;
string query = "Update patients SET First = '" + txtFirst.Text
+ "', Last='" + txtLast.Text
+ "', Address='" + txtAddress.Text
+ "', Phone='" + txtPhone.Text
+ "', LastVisit='" + txtLastVisit.Text
+ "', NextVisit='" + txtNextVisit.Text
+ "', Doctor='" + comboDoctor.Text
+ "' WHERE patients.ID =" + lblID.Text + " ";
command.CommandText = query;
command.ExecuteNonQuery();
MessageBox.Show("User Updated");
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show("User not updated " + ex);
}
}