| Bug #5897 | missing Reference in DbType setter | ||
|---|---|---|---|
| Submitted: | 5 Oct 2004 10:08 | Modified: | 13 Oct 2004 16:35 |
| Reporter: | Roman Kunert | ||
| Status: | Closed | ||
| Category: | Connector/Net | Severity: | S2 (Serious) |
| Version: | 1.0.0 | OS: | Microsoft Windows (Windows 2000) |
| Assigned to: | Reggie Burnett | Target Version: | |
[5 Oct 2004 15:50]
Roman Kunert
I just saw that in the same class you find the lines:
public MySqlDbType MySqlDbType
{
get
{
return paramValue.MySqlDbType;
}
set
{
if (paramValue != null && value == paramValue.MySqlDbType) return;
paramValue = MySqlValue.GetMySqlValue( value, false, true );
}
}
here it was done correctly, so one just needs to copy the above line...
[13 Oct 2004 16:35]
Reggie Burnett
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.
If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information
about accessing the source trees is available at
http://www.mysql.com/doc/en/Installing_source_tree.html

Description: If you construct a MySqlParameter Object with the default constructor the member variable paramValue does not get initialized. While the DbType property setter tries to access paramValue a System.NullReferenceException is thrown, the problem is the line with the if clause: public DbType DbType { ... set { if (value == paramValue.DbType) return; paramValue = MySqlValue.GetMySqlValueFromDbType( value ); } } How to repeat: MySqlCommand com = new MySqlCommand(); MySqlParameter param = com.CreateParameter(); param.DbType = DbType.Int16; Suggested fix: either initialize paramValue in the default constructor or prepend "if(paramValue!=null)"...