Click here to Skip to main content
15,921,382 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
User already exits in stored procedure ?

When enter duplicate username alert message is display User Name is already exits ?
Posted
Comments
Abhinav S 6-Sep-12 8:14am    
Tried anything?
[no name] 6-Sep-12 8:15am    
Please improve your question. it is not clear.
You can also share some of your code.
ZurdoDev 6-Sep-12 8:16am    
This is not clear at all. Just a guess, but check to see if the user exists in whatever your table is and if it does, return a message.

you can check it by using select query with where condition on user name if it will return any record then you can say that your user name is already exists in database.


or if you have put any unique contain on username then while inserting same username in database then it will throw error for violating unique constrain. so on that error filtering with that error message you can say that your user is already exists in database.
 
Share this answer
 
Have you tried google[^]

A simple search with your question gives 2,320,000 results, and many of those search results surely solve your problem.

Try something first, although you are a beginner. This is not at all appropriate Dhaval. Try something by your side first and then post your question if you get stuck'd somewhere.
 
Share this answer
 
SQL
IF Not Exists(SELECT fieldname FROM fieldmaster WHERE fieldname = @fieldname)
    insert into fieldmaster (fieldname, tooltip, label,labelalign, controltype, controlalign,
     [values], defaultvalues, minlength, maxlength, [required], [validation], isactive)
     values (@fieldname, @tooltip, @label, @labelalign, @controltype, @controlalign,
     @values, @defaultvalues, @minlength, @maxlength, @required, @validation, @isactive)
    END




SQL
BEGIN
    IF Exists (select id  from fieldmaster where fieldname = @fieldname)
    BEGIN
    Declare @ids as int = 0
    select @ids = id from fieldmaster where fieldname = @fieldname
    if(@id=@ids)
    BEGIN
    Update fieldmaster set fieldname = @fieldname, tooltip=@tooltip, label=@label, labelalign=@labelalign,
     controltype= @controltype, controlalign=@controlalign, [values]= @values, defaultvalues=@defaultvalues,
     minlength=@minlength, maxlength= @maxlength, [required]= @required, [validation] =@validation, isactive = @isactive where id = @id
    END
    END
    ELSE
    BEGIN
    Update fieldmaster set fieldname = @fieldname, tooltip=@tooltip, label=@label, labelalign=@labelalign,
     controltype= @controltype, controlalign=@controlalign, [values]= @values, defaultvalues=@defaultvalues,
     minlength=@minlength, maxlength= @maxlength, [required]= @required, [validation] =@validation, isactive = @isactive where id = @id
    END
    END
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900