Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
1.20/5 (5 votes)
See more:
hi Write a program that stores 10 user names. When the user re-enters his name the program should display the message “Already Exists”.
Posted
Updated 19-Dec-10 18:51pm
v2
Comments
Sandeep Mewara 20-Dec-10 0:51am    
No effort!
Richard MacCutchan 20-Dec-10 3:55am    
Better idea, you write it; who knows, you may learn something along the way.

Use stored procedure (if you are using database):

SQL
CREATE PROCEDURE spempcheck
(
    @empid varchar(50),
    @status char(1) output 
)
Begin
    declare @cnt int
    declare @errmsg varchar(1000)
    
    select @cnt=count(*) from Emp where Emp_id=@Empcode
    if(@cnt>0)
       begin
          set @status='T'
       end
    else
       begin
          set @status='F'
       end
End


Then inside your code check whether the Stored Procedure is returning T or F. If T then show message "Record already exists"
 
Share this answer
 
v2
Comments
hilbert hussen 19-Dec-10 22:32pm    
sir,
how do we wrinte in .net using console application
Wild-Programmer 19-Dec-10 22:37pm    
Let me know what all are you using in your project?
TweakBird 19-Dec-10 22:54pm    
Good call.
Wild-Programmer 19-Dec-10 22:58pm    
Thanks Eswa :)
Sandeep Mewara 20-Dec-10 0:52am    
Kindly avoid providing full codes to someone just posting problem statement(without showing any effort). It would not help the OP in longer run. We are here to help and make them learn.

Rest, good going. Keep it up. :)
using Dictionary to store the username and password

username is the key of the Dictionary and .Duplication occur it will throw the Exception
 
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