从 .NET TableAdapter 调用的具有参数化参数的 MySQL 存储过程不过滤数据

发布于 2024-11-06 19:52:50 字数 1281 浏览 1 评论 0原文

我正在使用连接字符串直接连接到我的本地 MySql 数据库。当我尝试以下操作时:

Dim dtUsers As New dtUsers.UsersDataTable

Dim taUsers As New dtUsersTableAdapters.UsersTableAdapter

dtUsers = taUsers.GetDataByUsername_Password("useracct1", "userpw1")

当我在调试模式下查看 dtUsers 的结果时,它返回数据库中的所有行,并且不会将它们过滤为仅包含用户名:useracct1 和密码:userpw1 的记录。

存储过程在 MySql Workbench GUI 中正确执行,但由于某种原因,结果未被过滤。我还没找到有同样问题的人。

MySql 存储过程如下所示:

-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=(backtickhere)root(backtickhere)@(backtickhere)localhost(backtickhere) PROCEDURE (backtickhere)Users_ByUsername_Password(backtickhere)(IN Username VARCHAR(25),
    IN Password VARCHAR(25))
BEGIN
   SELECT     ID, Email, Password, DoB, Status, SessionID, FirstName, LastName, Icon, Username, Quote, Location, ImgType, PrivateAcct, CommentNotify, TaggedNotify,
                      FollowedNotify
   FROM         Users
   WHERE     (Username = @Username) AND (Password = @Password);
END

所有内容也在强类型数据集中的 TableAdapter 中正确定义和设置。

I am using a connection string to directly connect to my local MySql database. When I try the following:

Dim dtUsers As New dtUsers.UsersDataTable

Dim taUsers As New dtUsersTableAdapters.UsersTableAdapter

dtUsers = taUsers.GetDataByUsername_Password("useracct1", "userpw1")

When I look at the results of dtUsers in debugging mode, it returns all of the rows from the database and isn't filtering them to only the record with the username: useracct1 and the password: userpw1.

The stored procedures execute correctly in the MySql Workbench GUI, but for some reason, the results are not being filtered. I haven't been able to find anyone with this same issue.

MySql Stored Procedure looks like the following:

-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $

CREATE DEFINER=(backtickhere)root(backtickhere)@(backtickhere)localhost(backtickhere) PROCEDURE (backtickhere)Users_ByUsername_Password(backtickhere)(IN Username VARCHAR(25),
    IN Password VARCHAR(25))
BEGIN
   SELECT     ID, Email, Password, DoB, Status, SessionID, FirstName, LastName, Icon, Username, Quote, Location, ImgType, PrivateAcct, CommentNotify, TaggedNotify,
                      FollowedNotify
   FROM         Users
   WHERE     (Username = @Username) AND (Password = @Password);
END

Everything is also defined and setup correctly in the TableAdapter in the strongly typed DataSet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文