Bug #14688 Object reference not set to an instance of an object. Output parameter not set
Submitted: 6 Nov 2005 23:45 Modified: 7 Nov 2005 10:19
Reporter: greg perowne Email Updates:
Status: Not a Bug Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:1.0.6 527 OS:Microsoft Windows (Windows XP)
Assigned to: CPU Architecture:Any

[6 Nov 2005 23:45] greg perowne
Calling a stored procedure that returns multiple resultsets and output parameters results in an exception.

Object reference not set to an instance of an object. Due to null value in output parmeter.

How to repeat:
I will attach a c# Web project with Visual studio project files and MySQL script to recreate the problem.

The web app displays a button. Clicking the button calls a stored proc returning three result sets and an output param.

If the lines attempting to read the output param are commented out then three datagrids are populated correctly.
[6 Nov 2005 23:56] greg perowne
Web Project and script file to produce problem

Attachment: Bugtest.zip (application/x-zip-compressed, text), 10.24 KiB.

[7 Nov 2005 0:09] greg perowne
The problem occurs regardless of whether or not there are additional results with the output parameter. It appears that MySqlDataReader cannot handle output parameter results.
[7 Nov 2005 9:12] greg perowne
Just to prove the point by commenting out the ExecuteReader and the NextResult() code, and adding  myCommand.ExecuteNonQuery(); The output parameter is returned correctly.

Of course this isn't a workaround because you have to use ExecuteReader when a sp returns resultsets and output parameters.
[7 Nov 2005 10:19] greg perowne
OK this is most probably by design. The parameters are populated fine as long as the Close() is actioned prior to obtaining the parameter.value. There is obviously a slight discrepency between the behaviour of SQLDataReader and MySqlDataReader. But having moved the close() it works fine.