Before anyone starts shouting "duplicate", let me say that I've searched for a solution to this problem thoroughly, and found no solutions.
Background info: I'm attempting to inset into a small table in an Access 2003 database from a compiled windows form program (exe) made with Visual Basic 2010 Express.
There are four insert statements performed in this same database, each on a different table, but the first three work without issue, it's the fourth one that throws the error:
cmd = New OleDbCommand("INSERT INTO PrivateTableName
VALUES('" & Serial.Text & "','Pending',
'" & coverArea.Text & "','')", myConnection)
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Error attempting to insert into PrivateTableName " & ex.ToString)
Exit Sub
End Try
I've changed the name of the table for privacy purposes, but rest assured, the table name is irrelevant.
This statement throws the exception
The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship
The error itself is pretty self-explanatory, yet, utterly impossible. Below is a screen shot of the table design
Note that the primary key is not an auto incrementing number. The primary key is a serial number (or rather a string) which is consists of a 5 digit number (which is sequentially indexed from the previous) and two letters which are randomly generated (i.e. 14582KH), and I've verified that the value it attempts to insert as the primary key doesn't already exist.
I've already tried to compact and repair the database, which didn't help. There are no relationships between the fields in this table with fields in other tables, it's completely independent.
Any ideas?
Though I'm unsure why it matters, specifying the fields seems to fix the problem.
cmd = New OleDbCommand("INSERT INTO PrivateTableName ([My Order Number],
[BV Order Number], [Area]) VALUES('" & Serial.Text & _ "','Pending'," &
coverArea.Text & ")", myConnection)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다