|
-
Feb 3rd, 2001, 05:16 AM
#1
Thread Starter
Addicted Member
Dear My Friends,
I wish to ask a question about updating data in a MS Access database which I use ADO for connecting.
Suppose my program allows the use to import data from a delimited text datafile and the primary key of the database is
stockcode;date
If the user click the import button twice, the error (-2147467259) will occur:
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."
So I wish to trap this error and prompt the user whether to overwrite the existing data item or cancel the insertion. I also wish to provide a checkbox "ALL" to allow the user to overwrite all data or just keep all existing data unchanged.
So can anyone give me some coding hints on how I can achieve this purpose. Thanks a lot.
-
Feb 3rd, 2001, 08:20 AM
#2
Junior Member
I would suggest against using a date as your key, but without knowing everything you are doing it's hard to say for sure.
With you using the term "trap" this error, I assume you know how to trap/ignore an error and then act on that?
-
Feb 3rd, 2001, 08:37 AM
#3
Fanatic Member
Why don't you set it up so that the code deletes all the records in the table before you import the data, this way you won't have to fiddle around with a messy error handler.
You might not be able to do this due to some other factor, but it is just a thought...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|