晚上好。
我无法使Mysql Update Statement运行。也许我缺少了一些东西。
相同的mysqlconnection可以完美地选择和插入数据。仅供参考,这些部分(选择和插入)被注释掉。
我收到以下4条错误消息:
MySqlConnection conn = DBUtils.GetDBConnection();
conn.Open();
MySqlCommand cmd = conn.CreateCommand();
string SQL_update = "UPDATE discordbot.tb_lurk SET lupo = lupo + 1 WHERE twitch = '68AFCDC29BFFBDAC4F59A43AE39AFF84'";
cmd.CommandText = SQL_update;
cmd.ExecuteNonQuery();
conn.Close();
工作台中的Tableview:https : //gyazo.com/858f51ea25c4b3526e95c64d5b40afd2
class DBMySQLUtils
{
public static MySqlConnection
GetDBConnection(string host, int port, string database, string username, string password)
{
// Connection String.
String connString = "Server=" + host + ";Database=" + database
+ ";port=" + port + ";User Id=" + username + ";password=" + password;
MySqlConnection conn = new MySqlConnection(connString);
return conn;
}
}
class DBUtils
{
public static MySqlConnection GetDBConnection()
{
string host = "ip-here";
int port = 3306;
string database = "discordbot";
string username = "discordbot";
string password = "pwhere";
return DBMySQLUtils.GetDBConnection(host, port, database, username, password);
}
}
完全例外:
MySql.Data.MySqlClient.MySqlException
HResult=0x80004005
Message=Fatal error encountered during command execution.
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
at sqltest.Program.Main(String[] args) in C:\Users\chaos\Dropbox\Visual Studio\Mysqltest\sqltest\sqltest\Program.cs:line 35
Inner Exception 1:
MySqlException: Fatal error encountered attempting to read the resultset.
Inner Exception 2:
MySqlException: Reading from the stream has failed.
Inner Exception 3:
IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Inner Exception 4:
SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
在此先感谢
好的,伙计们,我感谢所有尝试帮助我的人。
我发现了错误。Mysql Server在5.7.17版本上运行。我没有更新服务器,而是在Windowsserver 2012上安装了新版本的Mysql Benchmark。我无法打开新的Benchmark,但它解决了通信问题。
我不知道某些语句为什么起作用(插入,选择),但是UPDATE却不起作用。