Skip to content

Object cannot be cast from DBNull to other types when conn.open #4

@yucikala

Description

@yucikala

Software versions
Server type (MySQL, MariaDB, Aurora, etc.) and version: 10.11.2-MariaDB-log
.NET version: .NET 5.0

Describe the bug
When program try to connect, It crash... ("Object cannot be cast from DBNull to other types."

Exception
"Object cannot be cast from DBNull to other types."

at System.DBNull.System.IConvertible.ToInt32(IFormatProvider provider)
at MySql.Data.MySqlClient.Driver.LoadCharacterSets(MySqlConnection connection)
at MySql.Data.MySqlClient.Driver.Configure(MySqlConnection connection)
at MySql.Data.MySqlClient.MySqlConnection.Open()
at MysqlBackup.Program.ProcessServerExport(ConfigExclude excludeConfig, Server server) in D:\Projekty\smallprograms\MysqlBackup\Program.cs:line 145
at MysqlBackup.Program.Execute(Options opts) in D:\Projekty\smallprograms\MysqlBackup\Program.cs:line 90

Code sample
//connstring is with example values
constring = "server=myserver;Port=3306;user=userlogin;pwd="=password123456";database=dbName;convertzerodatetime=true;";
using (var conn = new MySqlConnection(constring))
{
using (var cmd = new MySqlCommand())
{
using (var mb = new MySqlBackup(cmd))
{
cmd.Connection = conn;
cmd.CommandTimeout = 99999;
conn.Open(); //here is the problem

/* A concise code sample to reproduce the bug */

Expected behavior
Normal connection. To other databases is ok, but i have one, where is problem.

The main problem is, that i can not change Mysql.Data to MysqlConnection. And new version ov MariaDB return null ID of collation.

see more mysql-net/MySqlConnector#1322

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions