Link to home
Start Free TrialLog in
Avatar of Cragly
Cragly

asked on

C# - Avoiding Duplicate Data

Hi All,

I have a asp.net 1.1/sql server 2000 web based administration system where I create and update records. What I want to do is to check that no record with the same name exists in the database before I create or update a record. I have managed to accomplish this with the create as I used a stored procedure to check if a record exists with the same name and return an output parameter depending on the result.

The problem I am having is that when I do an update on a record that has 3 fields I do a check on the name field and see if it exists before I allow the update just incase the user has changed the name to something that already exists in the system. However if the user has changed fields 2 or 3 but does not change the name then the update fails as it says the record already exists in the database.

ie
There are three fields:

Username
Password
DisplayUser

The stored procedure checks on update to see if the username already exists before it does the update. But if the administrator only changes the password the update will not work as the Username already exists in the database.

Can anybody help me out with this one??

Many thanks

Cragly
Avatar of csk_73
csk_73
Flag of Spain image

Hi Cragly,
can you post the stored procedures code? and the update code?

Hope this helps!

Cesc
ASKER CERTIFIED SOLUTION
Avatar of GavinMannion
GavinMannion

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cragly
Cragly

ASKER

Many thanks,

What I will do is check the username in the database with the updated username. If it has changed then I will check to see if there is an identical record with that username before I dop the update. If the username is the same then I can just do the update anyway as sugested.

Cheers

Cragly