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
Bhabani prasad DashPosted Apr 18, 2013, 2:07 AM
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
Jignesh TrivediPosted Mar 21, 2013, 12:23 AM
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.
brunda kPosted Mar 20, 2013, 11:47 AM