2
I am trying to load an image saved in Mysql, however still unsuccessful. With the code below I can display all other fields. Every time I try to add some method to display the image, some error occurs that does not display any search information.
MySqlConnection conn = new MySqlConnection("Server=localhost;Database=portaria;Uid=root;Pwd=''");
                conn.Open();
                //Inserindo um comando para acessar o funcionário cadastrado
                MySqlCommand consultar = new MySqlCommand(
                    "SELECT funcID, funcRG, funcNome, funcEmpresa, funcSetor, funcRamal, funcFoto, funcStatus " +
                    "FROM funcionario WHERE funcRG = ?", conn);
                consultar.Parameters.Clear();
                consultar.Parameters.Add("@funcRG",MySqlDbType.VarChar, 12).Value = txtRG.Text;
                consultar.CommandType = CommandType.Text;
                //Recebendo o conteúdo da pesquisa
                MySqlDataReader info;
                info = consultar.ExecuteReader();
                info.Read();
                //Passando as informações para os campos
                lblNumID.Text = info.GetString(0);
                txtNome.Text = info.GetString(2);
                txtEmpresa.Text = info.GetString(3);
                txtSetor.Text = info.GetString(4);
                txtFone.Text = info.GetString(5);
                //pictureCadastro.Text = info.GetString(6); ------>>>>> Falta carregar a imagem
                cBoxStatus.Text = info.GetString(7);
                conn.Close();
Can someone help me?
Pera, you want to play the image on a text field?
– Victor Laio
First, you are using the method
GetString()if the column stores a blob, it should be theGetBytes()... after, you are trying to play this content in aTextBox? An error message is displayed?– Leandro Angelo
I want to play the image in a pictureBox, I use the same element to save the image.
– Ronaldo Mendes