java datareader大小,MySQLDataReader not reading C#

If I were going to execute a procedure that was declared as:

CREATE PROCEDURE x(em VARCHAR, pw VARCHAR) --declaration of parameters

BEGIN

SELECT * FROM `user` WHERE `EmailAddress`= em AND `Password` = pw;

END

I would ensure the parameters in my C# code were named the same as in the declaration of the stored procedure:

cmd.Parameters.Add(new MySqlParameter("em", Email));

cmd.Parameters.Add(new MySqlParameter("pw", Password));

I suspect that your query is not getting any rows, because the values you set never make it into the parameters, and are hence never used to query. reader.Read() returns false, because there are no rows. Also make sure that the values for EMail and Password that you're querying really do exist in the table

Try as a debugging thing, to make your query like:

SELECT UserID, DisplayName, Moderator FROM `user` WHERE `EmailAddress`= @p0 AND `Password` = @p1

UNION ALL

SELECT 0, CONCAT_WS(' ', 'There is no user with email/password of', @p0, '/', @p1), '' FROM DUAL;

Or however your parameters are named now..

Your reader.Read()should now return true because this query should always return a row, so inspect the value of DisplayName, it should tell what search terms were applied

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值