473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Duplicate unique values

I have created a short routine to read certain data from an AS400 and put it
into a small table stored in Access (I know not the best data store, but it
is what we have for now).

Anyway, some of this data coming from the AS400 is duplicating a unique data
column and with the try...catch I get errored out and the sub exits.

Is there a way if a certain error occurs to disregard the added row to the
table and continue the sub instead of exiting out of the sub?

Thanks for any information.

Brad
Nov 20 '05 #1
2 1240

"Brad Allison" <ba******@ukcdogs.com> wrote in message
news:eY****************@TK2MSFTNGP09.phx.gbl...
I have created a short routine to read certain data from an AS400 and put it into a small table stored in Access (I know not the best data store, but it is what we have for now).

Anyway, some of this data coming from the AS400 is duplicating a unique data column and with the try...catch I get errored out and the sub exits.

Is there a way if a certain error occurs to disregard the added row to the
table and continue the sub instead of exiting out of the sub?


Why not:

A) Determine what type of exception is being thrown for this one particular
error and see if it's the same exception as any other data-related error
would throw. If so, find out what identifies this exception as the
"duplicate key" error (or whatever it is).

B) Wrap the statement that updates/adds the data in its own Try/Catch block.

C) In the Catch portion of B), use the results from A) to either test for a
different exception type or interrogate the exception data to see if you've
run into a duplicate key issue or something else. If something else, report
the error and exit the Sub. Otherwise, ignore the error and processing will
continue, effectively ignoring the duplicate data.
Nov 20 '05 #2
Thanks, it worked. The err.number happens to be "5" so when it hits that
number, I just have the dataset clear that row.

Thanks for the advice.

Brad
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

"Brad Allison" <ba******@ukcdogs.com> wrote in message
news:eY****************@TK2MSFTNGP09.phx.gbl...
I have created a short routine to read certain data from an AS400 and put
it
into a small table stored in Access (I know not the best data store, but it
is what we have for now).

Anyway, some of this data coming from the AS400 is duplicating a unique

data
column and with the try...catch I get errored out and the sub exits.

Is there a way if a certain error occurs to disregard the added row to

the table and continue the sub instead of exiting out of the sub?


Why not:

A) Determine what type of exception is being thrown for this one

particular error and see if it's the same exception as any other data-related error
would throw. If so, find out what identifies this exception as the
"duplicate key" error (or whatever it is).

B) Wrap the statement that updates/adds the data in its own Try/Catch block.
C) In the Catch portion of B), use the results from A) to either test for a different exception type or interrogate the exception data to see if you've run into a duplicate key issue or something else. If something else, report the error and exit the Sub. Otherwise, ignore the error and processing will continue, effectively ignoring the duplicate data.

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: g_chime | last post by:
I'm sorry, I had a couple of typos in my original post. Here is the corrected version: How can I make MySQL reject duplicate rows when inserting? The table is quite large: 100+ columns and...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
8
by: mindwarp | last post by:
Hi, When a user submits / posts data my php script Inserts data into my database. If they refresh the script or click back and click submit again I get duplicate record. Is there an easy...
4
by: FangQ | last post by:
hi I am very new to mysql. I have a question about using the "on duplicate update" clause with insert command. my table "data" has two columns, field1 and field2, where field1 is the index...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
4
by: SJ | last post by:
Hi! I am trying to do a simple udpate on a table and I am getting the error: "Cannot insert duplicate key row in object 'UserInfo' with unique index 'UserInfo_Login'.The statement has been...
9
by: DotNetNewbie | last post by:
Hello, I need a simple hash algorithm that will detect duplicate content in my application. I want to hash not just the content, but a few other parameters also like EmployeeID and...
4
by: ramdil | last post by:
Hi All I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns Now i have problem with the table,as my...
7
by: php_mysql_beginer911 | last post by:
Hi .. i am trying to update a table where if field contents any duplictaed entries than one of the field should be updated with random number which is unique so i can make all entries unique i...
4
by: Thomas Arthur Seidel | last post by:
Hello to all, I have a small or big problem with a customer data base, where during a change of system we might have created duplicate records. This should be easy to find, you might think, but,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.