MySqlException not trapped in try/catch block

MySqlException not trapped in try/catch block

am 29.05.2007 21:21:09 von randallp

------_=_NextPart_001_01C7A226.838B422D
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello,

=20

I have a long running query that generates a MySqlException due to the
query timing out. It takes about 55 seconds to run on our production
server. The MySqlException is NOT being trapped in my try/catch block.

=20

Here is the error:

=20

MySql.Data.MySqlClient.MySqlException was unhandled

Message=3D"You are not owner of thread 58"

Source=3D"MySql.Data"

ErrorCode=3D-2147467259

Number=3D1095

StackTrace:

at MySql.Data.MySqlClient.MySqlStream.OpenPacket()

at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64&
affectedRows, Int64& lastInsertId)

at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()

at MySql.Data.MySqlClient.MySqlDataReader.NextResult()

at
MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBeh avior
behavior)

at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()

at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()

at MySql.Data.MySqlClient.MySqlCommand.Cancel()

at MySql.Data.MySqlClient.MySqlCommand.TimeoutExpired(Object
commandObject)

at System.Threading._TimerCallback.TimerCallback_Context(Object
state)

at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)

at System.Threading._TimerCallback.PerformTimerCallback(Object
state)

=20

=20

Here is my C# code:

=20

try

{

DateTime datStop =3D DateTime.Today;

DateTime datStart =3D datStop.AddDays(-29);

=20

strSQL =3D String.Format("CALL
sp_webReport_Graph_GetUpdatesInstalled_ByDay('{0}', '{1}')",

datStart.ToString("yyyy-MM-dd 00:00:01"),

datStop.ToString("yyyy-MM-dd 23:59:59"));

=20

objConnection =3D new MySqlConnection(m_strConnectionString);

objCommand =3D new MySqlCommand(strSQL, objConnection);

objCommand.CommandTimeout =3D 30; // <== Can increase to =
60 to
prevent error.

objDataAdapter =3D new MySqlDataAdapter(objCommand);

=20

objConnection.Open();

objDataAdapter.Fill(objDataSet); // <== Error occurs =
here.

}

catch (MySqlException MySqlEx)

{

string strMessage =3D MySqlEx.Message; // <== Why is is not =
trapped
here??

}

finally

{

// Close the connection to the database if it is open.

if (objConnection.State == ConnectionState.Open)
objConnection.Close();

=20

// Clean up MySQL objects.

objConnection.Dispose();

objDataAdapter.Dispose();

}

=20

=20

The error occurs on the line:

=20

objDataAdapter.Fill(objDataSet);

=20

If I increase the CommandTimeout to 60 it works without error.

=20

My question is why does the MySqlException not get handled in my catch
block?

=20

Thanks,

=20

Randall Price

Secure Enterprise Technology Initiatives

Microsoft Implementation Group

Virginia Tech Information Technology

1700 Pratt Drive

Blacksburg, VA 24060

Email: Randall.Price@vt.edu

Phone: (540) 231-4396

=20


------_=_NextPart_001_01C7A226.838B422D--

Re: MySqlException not trapped in try/catch block

am 31.05.2007 18:04:02 von Jess Balint

On Tue, May 29, 2007 at 03:21:09PM -0400, Price, Randall wrote:
> I have a long running query that generates a MySqlException due to the
> query timing out. It takes about 55 seconds to run on our production
> server. The MySqlException is NOT being trapped in my try/catch block.

Randall,

Please consider posting to the Connector/NET list or forum.

Jess

--
MySQL ODBC Mailing List
For list archives: http://lists.mysql.com/myodbc
To unsubscribe: http://lists.mysql.com/myodbc?unsub=gcdmo-myodbc@m.gmane.org