好吧,我试图让程序不接受已经存在的记录,这些记录由" PRODNAME"使用SQL代码。
不知道如何以及在何处放置其他sql代码,因为我们的教授只是继续给我们的程序练习,甚至没有解释......它就像一个自我发现类T_T
由于这是我的代码的小部件:
verify = "SELECT * FROM Products"
recordset.Open(verify, connection, 3, 3)
If ... Then
recordset.AddNew()
recordset.Fields("prodSKU").Value = prodSKU.Text
recordset.Fields("prodName").Value = prodName.Text
recordset.Fields("prodSRP").Value = prodSRP.Text
recordset.Fields("ProdDesc").Value = prodDesc.Text
recordset.Fields("ProdUnit").Value = comboUnit.Text
recordset.Update()
recordset.Close()
MsgBox("Record added SUCCESS!", MsgBoxStyle.Information, "SUCCESS")
comboUnit.Items.Clear()
recordset.Open("SELECT DISTINCT Produnit FROM products", connection, 3, 3)
Do While Not recordset.EOF
comboUnit.Items.Add(recordset.Fields("Produnit").Value)
recordset.MoveNext()
Loop
recordset.Close()
Else
MsgBox("Duplicates found", MsgBoxStyle.Critical, "ERROR")
recordset.Close()
End If