Syntax error when opening a transaction with Connector/NET on MariaDB 10

2

I'm trying to connect my web application to a MariaDB 10 server. I already do it without problems on version 5 using MySQL Connector/NET. With version 10 I receive an error before executing my query, when the software executes the BeginTransaction.

IDbConnection dbConnection=new MySqlConnection(connectionString);
dbConnection.BeginTransaction();

The error is a classic:

[MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1]
MySql.Data.MySqlClient.MySqlStream.ReadPacket() +384
MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) +379
MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) +119
MySql.Data.MySqlClient.MySqlDataReader.NextResult() +901
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) +2308
MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() +133
MySql.Data.MySqlClient.MySqlConnection.BeginTransaction(IsolationLevel iso) +761
MySql.Data.MySqlClient.MySqlConnection.BeginDbTransaction(IsolationLevel isolationLevel) +19

I checked connector source code and it seems to happen when it executes

cmd.CommandText = "BEGIN";
cmd.ExecuteNonQuery();

in this file https://github.com/mysql/mysql-connector-net/blob/6.9/Source/MySql.Data/Connection.cs

I filed the question as a problem with Connector/NET but I receive the same error executing "BEGIN" with HeidiSQL so maybe it's a general problem.

It seems to be connected to delimiters but it sounds strange because it's a thing internal to the connector and both HeidiSQL and my software, simply changing connection string, works correctly on MariaDB 5.

I could be due to some server configuration?

.net
mariadb
mysql-connector
asked on Stack Overflow Jan 3, 2019 by Stevie B. Gibson • edited Jan 3, 2019 by Stevie B. Gibson

1 Answer

0

We had many issues with the original Connector/NET, there are well known bugs that you can't really work around, and the team behind the original connector (if there is even one) does not seem to care.

We ended up switching to the open source MySqlConnector which is awesome.

It implements the protocol from scratch, fixing an enormous list of known bugs in the official connector (see the bottom here).

It also ads some extra features such as true async functionality, etc.

Disclosure: I, and my team are in no way affiliated with the mentioned project, we just had to switch because of the bugs in the official project, and we are happy users ever since.

answered on Stack Overflow Jan 3, 2019 by Marcell Tóth

User contributions licensed under CC BY-SA 3.0