通过从c#.net调用存储过程来验证用户名和密码 [英] verifying username and password by calling stored procedure from c#.net

查看:69
本文介绍了通过从c#.net调用存储过程来验证用户名和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我编写了一个存储过程来检查用户名和密码,如下所示:

Hi,

I writes a Stored Procedure to check username and password that as follows:

create procedure Chk_UnamePWD
@UName varchar,@PWD varchar
as
begin
    select count(*) from tblCustomerVendorInfo where CVUserName=@UName and CVPassword=@PWD;
end

exec Chk_UnamePWD 'BBB','BBB'



即使给定的用户名和密码正确,存储过程也仅返回0(零).

请建议我解决这个问题.

谢谢

K Uday



Eventhough the given username and password is correct Stored Procedure is returns only 0(Zero).

Please advise me to solve this.

Thanks

K Uday

推荐答案

尝试通过以下方式找出答案

try to find Out in the following Way

Declare @Result int
if exists(select * from product  where name = 'product1')
begin
set @Result=1
select @result
end

else
begin
set @Result=0
select @Result
end


使用下一个部分查询测试该查询:
1:从tblCustomerVendorInfo中选择count(*);
您从表中获取所有值吗?

2:从tblCustomerVendorInfo中选择count(*),其中CVUserName = @ UName
你得到一个用户吗?

在此wau中,您可以查看基本查询或用户名是否错误.如果两种情况都返回期望值,则问题可能出在密码部分.
您要检查的内容在第二个测试查询上选择*.您是否看到详细信息,并且给定的密码与数据库中的密码匹配吗?
test the query with the next partial queries:
1: select count(*) from tblCustomerVendorInfo;
do you get all values from the table?

2: select count(*) from tblCustomerVendorInfo where CVUserName=@UName
do you get the single user?

in this wau you can see if the basic query or the username is wrong. If both cases return the expected values than the problem might be your password part.
what of you check select * on the second test query. Do you see the details and does the given password matches the one in the database?


尝试在Management Studio中使用select count(*) from tblCustomerVendorInfo where CVUserName=''BBB'' and CVPassword=''BBB'';并查看它是否返回任何行.值中可能存在一些前导或尾随空格.
Try using select count(*) from tblCustomerVendorInfo where CVUserName=''BBB'' and CVPassword=''BBB''; in management studio and see if it returns any row. May be there are some leading or trailing spaces in the value.


这篇关于通过从c#.net调用存储过程来验证用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆