The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Having trouble with a statement keep getting error number:-2147217873
Posted: 04 Oct 07 11:06 AM
|
I keep getting this error when inserting a new sale into our database. This is a custom table specific to our sales form. I keep getting this error: procedure Name: ExecuteSQL Error Number: -2147217873 Error description: The statement has terminated. :Cannot insert duplicate key row in object 'History' with unique index 'XPKHISTORY'
thanks |
|
|
| |
|
Re: Having trouble with a statement keep getting error number:-2147217873
Posted: 04 Oct 07 12:34 PM
|
Mario:
This error is coming from the DB, and it is indeed telling you that you are not inserting unique records as per defined on the referred index/constraint.
I would suggest you first determine what you are trying to insert and why it doesn't get past the Constraint:
- Analyze the XPKHistory index and determine what fields need to be unique. - Run the SLXProfiler to capture your SQL statements and examine them closer to figure out what is going on. |
|
|
| |
|
Re: Having trouble with a statement keep getting error number:-2147217873
Posted: 05 Oct 07 2:51 AM
|
Hi Mario,
Normally that should be fine for generating a new ID. However I have seen problems if records are bundled from one system and inserted into another. This is because Id's in the sitekeys table do not get updated to reflect the Ids used in the bundled records. Could this be the problem in your case? Check on the ID that is getting generated (just attach a debugger and step through the code or simply add a MsgBox to your code). To determine if it is already exists in the history table run the query:
SELECT Count(HistoryId) FROM History WHERE HistoryId = ''
If the query returns 1 the Id has already been used and records must have been inserted without updating the sitekeys table in which case you'll need to manually update it to fix the problem.
One other possibility that springs to mind is that there is a typo in your code on the line that generates the Id but you have used On Error Resume Next. This means that the Id used in your SQL insert would be an empty string. This would run OK once but subsequent runs would fail due to the fact there is already a HistoryId record with an ID of '' in the table. You can tell if this your problem by checking on the Id that is being generated as previously mentioned. If it's blank there's a problem in the code.
HTH. Darron |
|
|
|