Universal App MySQLConnector队列执行错误 [英] Universal App MySQLConnector Queue execution error
问题描述
我尝试使用PHPAdmin对虚拟服务器上的数据库执行队列,并且得到
I try to Execute a queue to my database on my vserver with PHPAdmin and i get the
例外:
代码:
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");
在以下位置引发异常:
MySqlCommand checkLogin = new MySqlCommand("SELECT * FROM UserData
;");
MySqlCommand checkLogin = new MySqlCommand("SELECT * FROM UserData
;");
我在UserData
和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 ?
推荐答案
问题是,我忘记为命令设置连接
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.
这篇关于Universal App MySQLConnector队列执行错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!