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

Closed
alanprot opened this issue Oct 28, 2016 · 1 comment

Comments

@alanprot
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()
@bgrainger
Copy link
Member

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
Labels
None yet
Development

No branches or pull requests

2 participants