我正在尝试更新 MS Access 表中的供应商记录,这是 DA 层中的代码:
更新供应商的方法
public static void updateVendor(Vendor aVendor)
{
try
{
String sSQLCommand = "UPDATE Vendor SET VendorID = '" + aVendor.VendorId + "', VendorName = '" + aVendor.Name
+ "', AddressNo = '" + aVendor.AddressNo + "', Address = '" + aVendor.Address + "', City = '"
+ aVendor.City + "', State = '" + aVendor.State + "', ZipCode = '" + aVendor.Zipcode + "', PhoneNumber = '"
+ aVendor.PhoneNumber + "' WHERE VendorID = '" + aVendor.VendorId + "'";
// Create the command object
if (aConnection.State == ConnectionState.Closed)
aConnection.Open();
OleDbCommand cmd = aConnection.CreateCommand();
cmd.CommandText = sSQLCommand;
// Execute the SQL command
cmd.ExecuteNonQuery();
aConnection.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
我没有收到任何错误,但它不会更新表格,所以我不确定它有什么问题,你看到有什么问题吗?