my question is i have two columns
1st is employeeid
2nd is employeename
employee id is primary key...
but i also want that employeename also unique..so how can i do on click of submit button.if employee name is match wid other colum..then message is display tht already exists..
i want thaat solution in LINQ
Loading

brunda kRank #3,804 · 389 reputationPosted Mar 20, 2013, 7:47 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 20, 2013, 8:23 PM EDT
hi,
In this case you can also check whether emp name already exists in system (database) by select query.
or you can also put UNIQUE Constraints on database column.
please refer
http://msdn.microsoft.com/en-IN/library/ms191166%28v=sql.105%29.aspx
are you use LINQ to SQL or LINQ to Entity?
hope this will help you.
Bhabani prasad Dash168 reputationPosted Apr 17, 2013, 10:07 PM EDT
if u want to to check user exist or not just check it through stored procedure and call the proc from your application .i just write the stored proc u just call from app if u dont get plz repl me my mail id [email protected]
CREATE PROCEDURE sp_EMPLOYEEINFORMATION
@EMPLOYEEID varchar(50),
@EMPLOYEENAME varchar(50),
@ERROR VARCHAR(100) OUT
AS
BEGIN
SET NOCOUNT ON;
---Checking Condition if User exists or not if user not exists returns different message if exists returns different message
IF NOT EXISTS(SELECT * FROM TABLENAME WHERE EMPLOYEENAME =@EMPLOYEENAME )
BEGIN
INSERT INTO TABLENAME
(
EMPLOYEEID,
EMPLOYEENAME
)
VALUES
(
@EMPLOYEEID ,
@EMPLOYEENAME
)
--If User Successfully Registerd I am returing this Message as Output Parameter
SET @ERROR=@EMPLOYEENAME +' Registered Successfully'
END
ELSE
BEGIN
--If User already Exists i am returning this Message as Output Parameter
SET @ERROR=@EMPLOYEENAME + ' Already Exists'
END
END