I have this code snippet where it takes the information from a database field and passes it to the textBlock, so now I need to populate some textblock.
EX: In the database has name = maria Rg = 123 cpf = 456 ai in the program vai have the textblock that will take name, Rg, Cpf.
Code:
using (_connection = new MySqlConnection("Database=test;Data Source=localhost;User Id=root;Password=teste;SslMode=None;"))
{
System.Text.EncodingProvider ppp;
ppp = System.Text.CodePagesEncodingProvider.Instance;
Encoding.RegisterProvider(ppp);
_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"));
}
}
}