Friday, August 20, 2010

How to avoid entering duplicate in Database? I have already put an Index to the field so that the data will?

not be duplicated..My only problem is that error. The error always appear when i put the same data in the databse, and after that those duplicates were deleted from the database...how can I trap the error? the error is like this:





Run-time error '-2147467259 (80004005)





i try to trap it but it doesn't work that error always appear...


is their any alternative way to avoid entering duplicates in the database? or What is the right way to trap the error? Please help me i really need this to my thesis...Im now online this is my I.d ericgri20002000.


By the way im using ADO control and Datagrid ...PLease help meHow to avoid entering duplicate in Database? I have already put an Index to the field so that the data will?
You use create a constraint and create a unique key across the fields you don't want duplication. Most DB Engines allow you to specify to ignore duplicate records in a unique key field range. An Identity field doesn't necessarily remove duplicate values in supplement fields- only the ID field.





runtime error 80004005 refers to unrecognized database format.. what is the version of your access database? use Jet Ver 4.0 for access 2000/2003.. Jet 3.5.1 for access 97.. take careHow to avoid entering duplicate in Database? I have already put an Index to the field so that the data will?
Create a method to verify that the data that you鈥檙e entering does not already exist prior to updating your table in the database. The method should execute a stored proc that will simply query the table for the specified value and then return the record ID if it exists. If it鈥檚 already there, then just don鈥檛 attempt to perform the insert.





If you wanted to get more complicated you could use Ajax to check the database for the value as the user is actually typing it on the page and instantly notify the user that the value already exists preventing them from inserting the duplicate value on the client side. You would need to develop a Web service for this and learn how to use Ajax.NET or write your own JavaScript SOAP call methods to interact with the Web service.

No comments:

Post a Comment