all groups > sql server programming > september 2006 >
You're in the

sql server programming

group:

retriev employee information with the help of password encryption


retriev employee information with the help of password encryption Muhammad Ahsin Saleem
9/24/2006 10:39:19 PM
sql server programming: i have a problem that i have encrypted the user password but don't know


how to retrieve information against that user i have written a store
procedure but it does not work kindly if any body can help me, then do
help me its urgant


i have 4 collums in my tbl_login table
1=2E emp_name char 50 pk
2=2E uid char 20
3=2E cat char 10
4 pwd char 20
I have a form for login which takes input from the user. Input fields
are
1=2E User ID
2=2E User Password (pwd)
3=2E Category (cat)
after taking this information from user I have to check the user
validatioin If a user with the same uid, cat and pwd exist then I have
to select His/Her Name from table. When I run this store procedure
ALTER PROCEDURE dbo.SelectUserLogin
(
@id char(20),
@pwd char(20),
@cat char(10)


)
as
select * from tbl_login where uid=3D@id and cat=3D@cat


if (select pwdcompare(@pwd,pwd,0) from tbl_login) =3D 1
Return


Input values for this stored procedure are ahsin,ahsin123,Admin
it gives me following result with exception in it.
emp_name uid
cat pwd
-------------------------------------------------- --------------------



---------- --------------------
Muhammad Ahsin Saleem ahsin
Admin Subquery returned more than 1 value. This is not permitted
when the subquery follows =3D, !=3D, <, <=3D , >, >=3D or when the subquery=
is
used as an expression.
(1 row(s) returned)
@RETURN_VALUE =3D -6=20
Finished running dbo."SelectUserLogin".
Re: retriev employee information with the help of password encryption Mikhail Berlyant
9/24/2006 10:57:38 PM
In your version of proc below, the problem is in line
if (select pwdcompare(@pwd,pwd,0) from tbl_login) = 1

select pwdcompare(@pwd,pwd,0) from tbl_login returns as many records as in
table tbl_login and this is not allowed when subquery is followed by = in
this case

Original version of this proc you submitted 9/21 looked much better, but as
Hugo mentioned - it is hard to help you as you haven't provided info of what
actually the problem that you have

Mikhail Berlyant
Eng.Manager
Yahoo! Music

[quoted text, click to view]
i have a problem that i have encrypted the user password but don't know


how to retrieve information against that user i have written a store
procedure but it does not work kindly if any body can help me, then do
help me its urgant


i have 4 collums in my tbl_login table
1. emp_name char 50 pk
2. uid char 20
3. cat char 10
4 pwd char 20
I have a form for login which takes input from the user. Input fields
are
1. User ID
2. User Password (pwd)
3. Category (cat)
after taking this information from user I have to check the user
validatioin If a user with the same uid, cat and pwd exist then I have
to select His/Her Name from table. When I run this store procedure
ALTER PROCEDURE dbo.SelectUserLogin
(
@id char(20),
@pwd char(20),
@cat char(10)


)
as
select * from tbl_login where uid=@id and cat=@cat


if (select pwdcompare(@pwd,pwd,0) from tbl_login) = 1
Return


Input values for this stored procedure are ahsin,ahsin123,Admin
it gives me following result with exception in it.
emp_name uid
cat pwd
-------------------------------------------------- --------------------



---------- --------------------
Muhammad Ahsin Saleem ahsin
Admin Subquery returned more than 1 value. This is not permitted
when the subquery follows =, !=, <, <= , >, >= or when the subquery is
used as an expression.
(1 row(s) returned)
@RETURN_VALUE = -6
Finished running dbo."SelectUserLogin".

Re: retriev employee information with the help of password encryption Augustin Prasanna
9/25/2006 12:00:00 AM
Hi Muhammad,

Shouldn't you be doing something like this?

"select * from tbl_login where uid = @uid and cat=
@cat and pwdcompare(@pwd, pwd) = 1"

where pwdcompare will be an UDF that compares and returns a boolean value.

Also 'the object reference' error is because the dataset instance is not
created. you should check if the object instance is created before accessing
it's property.

Regards,
Augustin
http://augustinprasanna.blogspot.com


[quoted text, click to view]
actual problem is that it gives an exception which is
Subquery returned more than 1 value. This is not permitted
when the subquery follows =, !=, <, <= , >, >= or when the subquery is
used as an expression

and when I want to check whether any row is selected or not
If ds.Tables("tbl_login").Rows.Count = 0 Then
end if
it gives an error
"object refrence not set to an instance"

if you need any more information do tell me very clearly what u want to
know about the DB.

[quoted text, click to view]

Re: retriev employee information with the help of password encryption Muhammad Ahsin Saleem
9/25/2006 12:52:23 AM
actual problem is that it gives an exception which is
Subquery returned more than 1 value. This is not permitted
when the subquery follows =3D, !=3D, <, <=3D , >, >=3D or when the subquer=
y is
used as an expression

and when I want to check whether any row is selected or not
If ds.Tables("tbl_login").Rows.Count =3D 0 Then
end if
it gives an error
"object refrence not set to an instance"

if you need any more information do tell me very clearly what u want to
know about the DB.

[quoted text, click to view]
AddThis Social Bookmark Button