c# - 未能为字段分配正确的值?

标签 c# mysql .net database

由于某种原因,即使我为其分配的字段“Rank”为 0,但在数据库中当前它设置为 8。

using (var dbConnection = Program.Server.DatabaseHandler.Connection)
{
    dbConnection.SetQuery("SELECT users.id,users.username,users.rank,users.motto,users.look,users.gender,users.last_online,users.credits,users.activity_points,users.home_room,users.block_newfriends,users.hide_online,users.hide_inroom,users.vip,users.account_created,users.vip_points,users.machine_id,users.volume,users.chat_preference,users.focus_preference,users.pets_muted,users.bots_muted,users.advertising_report_blocked,users.last_change,users.gotw_points,users.ignore_invites,users.time_muted,users.allow_gifts,users.friend_bar_state,users.disable_forced_effects,users.allow_mimic,users.rank_vip " +
                          "FROM users " +
                          "JOIN user_auth_tickets " +
                          "ON users.id = user_auth_tickets.user_id " +
                          "WHERE user_auth_tickets.auth_ticket = @sso AND ip_last = @lastIp " +
                          "LIMIT 1"
    );

    dbConnection.AppendParameter("sso", authTicket);
    dbConnection.AppendParameter("lastIp", getIp());

    Load(dbConnection.ExecuteReader());
}

这是加载方法..

public void Load(MySqlDataReader reader)
{
    while (reader.Read())
    {
        Id = reader.GetInt32("id");
        Username = reader.GetString("username");
        Credits = reader.GetInt32("credits");
        Diamonds = reader.GetInt32("vip_points");
        Duckets = reader.GetInt32("activity_points");
        Gender = reader.GetString("gender").ToUpper() == "M" ? PlayerGender.Male : PlayerGender.Female;
        Motto = reader.GetString("motto");
        Outfit = new PlayerOutfit(HabboUtilities.GetFilteredFigure(reader.GetString("look").ToLower()));
        Rank = reader.GetInt32("rank");
        HomeRoom = reader.GetInt32("home_room");
        VipId = reader.GetInt32("rank_vip");
    }
}

最佳答案

问题是我的 SqlDataReader 无法从数据库中正确检索数据。

关于c# - 未能为字段分配正确的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48448273/

相关文章:

javascript - 使用 Jquery/Javascript 替换 CSS 属性

c# - 使用 Blazor 客户端应用程序实现事件订阅

c# - 线程安全队列 - Enqueue/Dequeue

c# - 关闭 dll 中的 Win32 对话框时出现异常(来自 WPF 应用程序)

mysql - 在 MySQL 上更新多列

mysql - 可以检查数字是否在 GROUP_CONCAT 中

c# - 自定义错误页面的重定向循环

MySQL:如何重组此代码以消除添加和删除中间列

c# - 继承和已知类型问题

.net - 我应该将配置文件放在 .NET 中的什么位置?