Universal App MySQLConnector Queue execution error

≡放荡痞女 提交于 2019-12-25 06:44:39

问题


I try to Execute a queue to my database on my vserver with PHPAdmin and i get the

Exception:

Code:

        static string server = "999.999.999.235";
    static string database = "admin_";
    static string user = "root";
    static string pswd = "secret";

    public static void login()
    {
        string connectionString = "Server = " + server + ";database 
        = "+ database + ";uid = " + user + ";password = " + pswd + ";" + "SslMode=None;" + "CharSet=utf8;";
        using (MySqlConnection connection = new 

    MySqlConnection(connectionString))
        {
            connection.Open();
            MySqlCommand checkLogin = new MySqlCommand("SELECT * FROM `UserData`;");
            using (MySqlDataReader reader = checkLogin.ExecuteReader())
            {
                reader.Read();
                string hash = reader.GetString("UserName");
                string salt = reader.GetString("Workbench");

The Exception is thrown at:

MySqlCommand checkLogin = new MySqlCommand("SELECT * FROM UserData;");

I tried it with UserData and UserData with and without ; same Exception. On the Server the Queue is working fine.

Question: Is the queue wrong or do I forget a configuration on the server ?


回答1:


The Problem was, that I forgot to set the connection for the command

connection.Open();
MySqlCommand checkLogin = new MySqlCommand("SELECT * FROM `UserData`",connection);

After adding the connection, all is working fine.



来源:https://stackoverflow.com/questions/36108468/universal-app-mysqlconnector-queue-execution-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!