Skip to content

Exception in MySqlCommand.Prepare #1083

Open
@george-polevoy

Description

@george-polevoy

Software versions
MySqlConnector version: 2.0.0
Server type (MySQL) and version: 5.7.32
.NET version: 5.0

Describe the bug
Exception in MySqlCommand.Prepare()

Exception

MySqlConnector.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
   at MySqlConnector.Core.ServerSession.PrepareAsync(IMySqlCommand command, IOBehavior ioBehavior, CancellationToken cancellationToken) in /_/src/MySqlConnector/Core/ServerSession.cs:line 219
   at MySqlConnector.MySqlCommand.Prepare() in /_/src/MySqlConnector/MySqlCommand.cs:line 112

Code sample

var cmdText = "CREATE FUNCTION echo(\nname VARCHAR(63)\n)\nRETURNS VARCHAR(63)\nBEGIN\nRETURN name;\nEND;";
			using var c = new MySqlConnection(MySqlTestsConfig.ConnectionString);
			c.Open();
			var cmd = c.CreateCommand();
			cmd.CommandText = cmdText;
			cmd.Prepare(); // THIS STATEMENT FAILS
			cmd.ExecuteNonQuery();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions