public bool CheckIDNO(string IDNO)
{
try
{
bool NoExists = false;
Database db = DAC.GetDataDBConnection();
DbCommand dbCmd = db.GetStoredProcCommand("CheckNO", IDNO, NoExists);
db.ExecuteScalar(dbCmd);
NoExists = (bool)db.GetParameterValue(dbCmd, "Exists");
if (NoExists)
return true;
else
return false;
}
catch (Exception ex)
{
throw ex;
}
}
source for SP
ALTER PROCEDURE [dbo].[CheckNO]
@IDNO varchar(25),
@Exists bit out
AS
BEGIN
SET NOCOUNT ON;
IF EXISTS(SELECT IDNO FROM Test WHERE IDNO = @IDNO )
begin
set @Exists= 1
end
else
set @Exists= 0
END
I hope this will help you