我目前遇到更新命令(OleDb)的问题。描述,类型和汇编字段正在更新;但是,部件号不是。部件号不是主键。我的代码如下。
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Office\Documents\SORINEX.accdb")
Dim DataInsert As String = "UPDATE Product SET [Product Type] = @ProductType, [Description] = @Description, [Assembly] = @Assy_Yes WHERE [Part Number] = @PartNumber"
con.Open()
Using cmd As New OleDbCommand(DataInsert, con)
cmd.Parameters.AddWithValue("@ProductType", Part_Type.Text)
cmd.Parameters.AddWithValue("@Description", Part_Description.Text)
cmd.Parameters.AddWithValue("@Assy_Yes", Assy_Yes)
cmd.Parameters.AddWithValue("@PartNumber", Part_Number.Text)
cmd.ExecuteNonQuery()
MessageBox.Show("Part Updated.")
End Using
con.Close()
谢谢!