Problem with Database Connection

Asked

Viewed 55 times

-1

Could you help me figure out why you’re making this mistake?

Code:

using (_connection = new MySqlConnection("Database=test;Data Source=localhost;User Id=root;Password=teste;SslMode=None;"))
{
    _connection.Open();
    var cmd = new MySqlCommand("select name from user where id=1", _connection);
    using (var reader = cmd.ExecuteReader())
    {
        if (reader.Read())
        {
            textBlock.Text = (reader.GetString("name"));
        }
    }
}

inserir a descrição da imagem aqui

  • Don’t forget to rate and accept the answer to your previous question: http://answall.com/questions/188832/conectar-com-mysql-universal-win-10

1 answer

0


Add the code below before opening the connection:

System.Text.EncodingProvider ppp;
ppp = System.Text.CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(ppp);

Response based in that reply.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.