Monday, March 26, 2012

problem with space

HI friends,
I've got one question. When I realize "log in" in my sql server, I am using
SP like this:
CREATE Procedure CustomerLogin
(
@.Email nvarchar(30),
@.Pwd nvarchar(10),
@.CustomerID int OUTPUT
)
AS
SELECT
@.CustomerID = CustomerID
FROM
Customers
WHERE
Email = @.Email COLLATE SQL_Latin1_General_CP1_CS_AS
AND
Pwd =@.Pwd COLLATE SQL_Latin1_General_CP1_CS_AS
IF @.@.Rowcount < 1
SELECT
@.CustomerID = 0
GO
The problem is that if the password is "qweqwe" and I try to log in with
"qweqwe " or even "qweqwe " (I mean with space after last symbol) it
succeed!!!
Interesting but if I try to log in with " qweqwe" (I mean with space in
beginning) it not succeed.
I don't know why. Could you please somebody help me?Because the trailing spaces are being removed. When you use
the password ' qweqwe' it's not a trailing space so it is
included in the string.
If you want to test to verify, just print out a
len(@.password) before the select.
-Sue
On Tue, 22 Feb 2005 01:45:47 -0000, "Mango"
<mitko762002@.yahoo.com> wrote:

>HI friends,
>I've got one question. When I realize "log in" in my sql server, I am using
>SP like this:
>CREATE Procedure CustomerLogin
>(
> @.Email nvarchar(30),
> @.Pwd nvarchar(10),
> @.CustomerID int OUTPUT
> )
>AS
>
>SELECT
> @.CustomerID = CustomerID
>
>FROM
> Customers
>
>WHERE
> Email = @.Email COLLATE SQL_Latin1_General_CP1_CS_AS
> AND
> Pwd =@.Pwd COLLATE SQL_Latin1_General_CP1_CS_AS
>
>IF @.@.Rowcount < 1
>SELECT
> @.CustomerID = 0
>GO
>
>The problem is that if the password is "qweqwe" and I try to log in with
>"qweqwe " or even "qweqwe " (I mean with space after last symbol) it
>succeed!!!
>Interesting but if I try to log in with " qweqwe" (I mean with space in
>beginning) it not succeed.
>I don't know why. Could you please somebody help me?
>

No comments:

Post a Comment