Is there an easy fix to my code to get the mysql Update statement working in csharp?

1

Good evening.

I cant get the Mysql Update Statement working. Maybe i am missing something.

The same mysqlconnection worked flawlessly to Select and Insert Data. FYI those sections(Select and Insert) are commented out.

I get following 4 error messages:

  • MySqlException: Fatal error encountered attempting to read the resultset.
  • MySqlException: Reading from the stream has failed.
  • IOException
  • SocketException

Full exception:

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

Thanks alot in advance

c#
mysql
.net
asked on Stack Overflow Jan 31, 2020 by Salt • edited Apr 1, 2020 by Salt

2 Answers

0

Two suggestions from me:

  1. Have you tried creating the command like this? var cmd = new MySqlCommand(SQL_update, conn); after opening the connection, then doing the cmd.ExecuteNonQuery(); ?

  2. Have you tried having the connection string looking like this instead? "SERVER=" + server + ";DATABASE=" + database + ";UID=" + username + ";PASSWORD=" + password;

... where "server" is ip/servername + port, like "myserver:3306". If server is local server, I THINK server can be "localhost" without port if the port is the standard port.

answered on Stack Overflow Jan 31, 2020 by Mats Magnem
0

Ok guys... I thank everyone single one of you who tried to help me.

I found the error. The Mysql Server was running on Version 5.7.17. I did not update the server but installed the new version of Mysql Benchmark instead on the Windowsserver 2012. I can not open the new Benchmark but it fixed the communication Problem.

I have no clue whatsoever why certain statements did work (Insert, Select) but UPDATE did not.

answered on Stack Overflow Jan 31, 2020 by Salt

User contributions licensed under CC BY-SA 3.0