Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing NullReferenceException when passing null parameter value to Query (MySqlParameter) #126

alanprot opened this issue Oct 28, 2016 · 1 comment


Copy link

alanprot commented Oct 28, 2016

To reproduce :

const string query = "select Col1 from Table1 where @parameter is null OR Col2 = @parameter";

using (var cmd = new MySqlCommand(query, con))
    cmd.Parameters.Add(new MySqlParameter() { ParameterName = "@parameter", Value = null });
    await cmd.ExecuteNonQueryAsync(cancellationToken);

Stack Trace:

at System.Object.GetType()
   at MySql.Data.MySqlClient.MySqlParameter.AppendSqlString(BinaryWriter writer, StatementPreparerOptions options)
   at MySql.Data.MySqlClient.MySqlStatementPreparer.ParameterSqlParser.DoAppendParameter(Int32 parameterIndex, Int32 textIndex, Int32 textLength)
   at MySql.Data.MySqlClient.MySqlParser.Parse(String sql)
   at MySql.Data.MySqlClient.MySqlStatementPreparer.ParseAndBindParameters()
   at MySql.Data.MySqlClient.MySqlCommand.<ExecuteReaderAsync>d__50.MoveNext()
Copy link

bgrainger commented Oct 28, 2016

Fixed in 0.6.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants