C#executioncalar不从存储过程返回值。 [英] C# executescalar not returning value from stored procedure.

查看:56
本文介绍了C#executioncalar不从存储过程返回值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试为我的网站实施表单身份验证,但在检查用户凭据时似乎无法让存储过程输出正确的值。代码是

hi i am trying to implemement forms authentication for my website but can''t seem to get the stored procedure to output the correct value when checking a users credentials. the code is

展开 | 选择 | Wrap | 行号

推荐答案

密码是否存储为哈希密码?条目是否相同 - 首先写入值以进行验证。
Is the password stored as a hashed password? Is the entry be the same - write the value first to verify.


首先,表格的结构是什么?


其次,当存储过程使用输出变量时,您不需要使用Return @Output返回输出变量,在这种情况下,您将返回一个值来验证如果程序正确运行 - 例如:


返回@@错误


@Output已包含输出值并将自动成为程序返回时返回。


如果要使用Return @ Output返回验证,则标题中不需要输出变量,因为所有存储过程都应返回一些整数值,通常这将用于验证过程是否成功完成 - 但没有什么可以说你不能用它来返回用户是否成功验证并丢弃标题中的输出参数。
Firstly, what''s the structure of your table holding the credentials?

Secondly, when a stored procedure is using output variables, you don''t need to return the output variable with Return @Output, in this instance, you would return a value to verify if the procedure ran correctly or not - for instance:

Return @@Error

@Output already contains the output value and will automatically be returned when the procedure returns.

If you want to return the validation using "Return @Output", then the output variable is not necessary in the header, as all stored procedures should return some integer value and usually this would be used to verify that the procedure completed successfully - but there''s nothing to say you couldn''t use it to return whether or not the user validated successfully and ditch the output parameter in the header.


嗨感谢您的回复。是的,密码是哈希的,当用户注册时和在验证用户登录时输入密码到数据库时我使用完全相同的代码
hi thanks for the replies. yes the password is hashed and i use exactly the same code when entering the password into the database when a user is registered and when validating the users login
展开 | 选择 | 换行 | 行号


这篇关于C#executioncalar不从存储过程返回值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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