1
Try {
if (cmbFavorecido.SelectedValue != null )
{
txtID.Text = cmbFavorecido.SelectedValue.ToString();
cn = conexao.ConectarSqlServer();
cn.Open();
SqlCommand cmd = new SqlCommand("select CNPJ_FORNECEDOR FROM FORNECEDOR WHERE ID_FORNECEDOR = " + txtID.Text, cn);
SqlDataAdapter ad = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ad.Fill(ds, "TbFornecedor");
txtCnpj.Text = ds.Tables["TbFornecedor"].Rows[0].ItemArray[0].ToString();
}
Post code, image is not recommended in this case.
– rubStackOverflow
As @rubStackOverflow already said, do not put an image of your code. Click on [Edit] and post the code itself. By the way, take a look at how to create a minimum, complete and reliable example and [Ask] =).
– Jéf Bueno
Okay, I posted the code, so if you can help me I’ll be grateful.
– Jhonatas Silva