Bug #78426 exception.number always 0
Submitted: 14 Sep 2015 4:34 Modified: 7 Nov 2022 17:25
Reporter: Christian Benner Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.8.6, 6.9.7 OS:Windows (Win 8 upto win 10)
Assigned to: CPU Architecture:Any

[14 Sep 2015 4:34] Christian Benner
Description:
 Try
            mySQLConn.Open()
            Return True
        Catch ex As MySql.Data.MySqlClient.MySqlException
            Select Case ex.Number
                Case 0

ex.number is everytime 0   

The innerException is: 1049

? ex.InnerException
{"Unknown database 'ber_orga'"}
    Data: {System.Collections.ListDictionaryInternal}
    ErrorCode: -2147467259
    HResult: -2147467259
    HelpLink: Nothing
    InnerException: Nothing
    Message: "Unknown database 'ber_orga'"
    Number: 1049
    Source: "MySql.Data"
    StackTrace: "   bei MySql.Data.MySqlClient.MySqlStream.ReadPacket##" & vbCrLf & "   bei MySql.Data.MySqlClient.NativeDriver.ReadPacket##" & vbCrLf & "   bei MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket##"
    TargetSite: {MySql.Data.MySqlClient.MySqlPacket ReadPacket##}

How to repeat:
Create a method with Code from Description with a Connection string with non existing database in scheme...

You'll see that exception.Number is 0

Suggested fix:
Repair the exception.number to reflect the right error.number
[14 Sep 2015 7:02] Chiranjeevi Battula
Hello Christian Benner,

Thank you for the bug report.
Verified this behavior on Visual Studio 2013 (C#.Net) with MySQL Connector/Net 6.9.7.

Thanks,
Chiranjeevi.
[14 Sep 2015 7:02] Chiranjeevi Battula
screenshots.

Attachment: 78426.zip (application/zip, text), 163.33 KiB.

[14 Sep 2015 7:09] Christian Benner
:-> It has nothing to do with the overlaying Visual Studio.
The same behaviour with the appliction itself (without Visual Studio)

also with Visual Studio 2015
[12 Mar 2017 22:14] Christian Benner
Still not fixed in latest .NET Connector
[23 Sep 2022 19:37] Omar Chavez
Posted by developer:
 
Verified using Connector/Net version 8.0.30
[7 Nov 2022 15:44] Omar Chavez
Posted by developer:
 
Changed a function that prevented showing the MySqlException.Number property for authentication-related exceptions
[7 Nov 2022 17:25] Christine Cole
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/NET 8.0.32 release, and here's the proposed changelog entry from the documentation team:

The MySqlException.Number property for authentication-related exceptions
always returned a value of zero.

Thank you for the bug report.