I wrote this function and now its always returning true…
can anybody help me?
Create FUNCTION dbo.ValidateBranch
(
@BranchID nvarchar(50),
@Password nvarchar(50)
)
RETURNS bit
AS
BEGIN
declare @Res bit
if exists(Select * From TPasswords Where (BranchID = @BranchID) and (isSecurity = 0) and (Pass = @Password))
set @Res = 1
else
set @Res = 0
RETURN @Res
END
and i’m callign like so:
bool isValidBranch = taQueries.ValidateBranch(IDBranch, PasswordTextBox.Text) ?? false;
The T-SQL code seems fine – how do you “always get back true” – in SQL Mgmt Studio, or from your app calling this function??
How are you calling this function, can you show us that piece of code??
I quickly recreated the setup and in my case, on SQL Server 2008 R2, it works just fine when I call this function like this: