7 messages in com.mysql.lists.dotnetRE: Wierd problem
FromSent OnAttachments
Jorge Bastos22 Feb 2005 04:37 
Reggie Burnett22 Feb 2005 08:03 
Jorge Bastos22 Feb 2005 08:08 
Kevin Turner22 Feb 2005 08:10 
Jorge Bastos22 Feb 2005 08:12 
Reggie Burnett22 Feb 2005 08:33 
Jorge Bastos22 Feb 2005 09:01 
Subject:RE: Wierd problem
From:Kevin Turner (kevi@coraltree.co.uk)
Date:02/22/2005 08:10:14 AM
List:com.mysql.lists.dotnet

Looks like you are closing the connection OK, but I can't see anything closing the datareader.....which is what the error message is telling you. I guess that can't be the problem you are referring to though because as far as I know you have always have to explicitly close a data reader before you can do anything else with the connection. I guess just closing the connection doesn't get rid of the datareader (connection pooling?)

-----Original Message----- From: Jorge Bastos [mailto:mysq@decimal.pt] Sent: 22 February 2005 12:38 To: dot@lists.mysql.com; Reggie Burnett Subject: Wierd problem

DecimalReggie, I got a serius issue here, i'm gonna try to reproduce some code to you take do the same and try, this is with driver 1.0.4

########## example 1 ########## dim mycon as new mysqlconnection("connection string") dim sql as string = "select max(id) from tbl_name" dim mycmd as new mysqlcommand(sql , mycon) dim myrd as mysqldatareader myrd=mycmd.executereader

if myrd.read msgbox "got some results" else msgbox "has a null result" end if

mycon.close() mycmd.dispose() ########## example 1 ##########

In the abobe example everything works fine because the max function will return the last value of the column "id"

########## example 2 ########## dim mycon as new mysqlconnection("connection string") dim sql as string = "select max(id) from tbl_name where id='laskdjflksdj'" <------ this where statment is impossible, mysql'll return a null value, ---> [NULL] dim mycmd as new mysqlcommand(sql , mycon) dim myrd as mysqldatareader myrd=mycmd.executereader

if myrd.read msgbox "got some results" else msgbox "has a null result" end if

mycon.close() <----------- like i'll have the value [NULL] returned, i get an error here, at the end of the email i show the output mycmd.dispose() ########## example 2 ##########

This was not happening with the previous drivers versions, i already had to change a bit of code to handle the situation. I'm almost sure that is something with the datareader that doesn't like the value [NULL] that mysql returns, can you confirm the driver bug and how can i resolve this? For now i've resolved inserting an try /catch

Output: MySql.Data.MySqlClient.MySqlException: There is already an open DataReader associated with this Connection which must be closed first. at MySql.Data.MySqlClient.MySqlCommand.CheckState() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader() at MySql.Data.MySqlClient.Driver.ShowWarnings(Int32 count) at MySql.Data.MySqlClient.NativeDriver.ReadEOF(Boolean readPacket) at MySql.Data.MySqlClient.NativeDriver.OpenDataRow(Int32 fieldCount, Boolean isBinary) at MySql.Data.MySqlClient.CommandResult.Consume() at MySql.Data.MySqlClient.MySqlDataReader.Close() at MySql.Data.MySqlClient.MySqlConnection.Close()