Bug #6001 System.Data.CommandBehavior.SingleRow causes probs
Submitted: 9 Oct 2004 22:34 Modified: 10 Dec 2004 20:21
Reporter: Timothy Parez Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:1.0 Beta 1 OS:Windows (XP Pro)
Assigned to: Reggie Burnett CPU Architecture:Any

[9 Oct 2004 22:34] Timothy Parez
Description:
Hi,

My application worked fine with 0.76, with the
exception of the authentication protocol for the latest
build of MySql 4.x

The changes commited in MySql.Data have caused me
lots of work but eventually I got it working.

Then I noticed that when using
System.Data.CommandBehavior.SingleRow
with a DataReader, the DataReader isn't always able to close.
In that case it stays open and the application just waits until it closes.

This bug has been reported on the sf.net page as I didn't know about this page:
https://sourceforge.net/tracker/?func=detail&atid=449819&aid=1043614&group_id=47556

How to repeat:
Anyway, all the code is working fine now except,
I had to change the following code:

(If you use SingleRow, the data reader won't always be able to close)

private void getSubCategorieDetails(int SubCategorieId)
{
/* Id,EnglishName,DutchName,ProductCategorie */
string query = "SELECT PRODUCTSUBCATEGORIE.Id,
PRODUCTSUBCATEGORIE.EnglishName,
PRODUCTSUBCATEGORIE.DutchName,
PRODUCTCATEGORIE.EnglishName As ProductCategorie FROM
PRODUCTSUBCATEGORIE INNER JOIN PRODUCTCATEGORIE ON
PRODUCTSUBCATEGORIE.HoofdCategorieId =
PRODUCTCATEGORIE.Id WHERE PRODUCTSUBCATEGORIE.Id =
?SubCategorieId";
MySqlCommand selectCommand = new
MySqlCommand(query,this.dbConnection);

selectCommand.Parameters.Add("?SubCategorieId",MySqlDbType.Int32).Value
= SubCategorieId;
MySqlDataReader dataReader =
selectCommand.ExecuteReader();
//System.Data.CommandBehavior.SingleRow

//There will only be one row
while (dataReader.Read())
{
//Update the GUI
this.txtId.Text = dataReader["Id"].ToString();
this.txtEnglishName.Text =
dataReader["EnglishName"].ToString();
this.txtDucthName.Text =
dataReader["DutchName"].ToString();
this.txtMainCategory.Text =
dataReader["ProductCategorie"].ToString();
this.lblSubCategorie.Text =
dataReader["EnglishName"].ToString();
}

dataReader.Close();

//Reset the changed flag
this.subCategorieChanges = false;

}

In the original version I had
MySqlDataReader dataReader =
selectCommand.ExecuteReader(System.Data.CommandBehavior.SingleRow);

But when I used this code, the DataReader never got
closed and the entire application would just hang.

So I had to change it to:
MySqlDataReader dataReader = selectCommand.ExecuteReader();

This should be fixed I assume?
[22 Oct 2004 19:18] Reggie Burnett
Can you test this with beta 2 that will be out in the next day or so?  I can't seem to repeat this.
[22 Oct 2004 20:19] Timothy Parez
Of course :)
[10 Dec 2004 20:21] Reggie Burnett
Thank you for taking the time to report a problem.  Unfortunately
you are not using a current version of the product your reported a
problem with -- the problem might already be fixed. Please download
a new version from http://www.mysql.com/downloads/

If you are able to reproduce the bug with one of the latest versions,
please change the version on this bug report to the version you
tested and change the status back to "Open".  Again, thank you for
your continued support of MySQL.

Additional info:

I haven't heard back so I am closing this bug.  Please repost the bug if it appears again.