There is no mapping of the System.Windows.Forms.Toolstriptextbox object type to a native type managed provider

Asked

Viewed 384 times

1

I’m having a problem trying to make an appointment at a Select and bring the information on TextBox.

There is no mapping of the System.Windows.Forms.Toolstriptextbox object type to a native type managed provider.'

Code:

if ((Keys)e.KeyChar == Keys.Enter)
        {

               SqlConnection con = ConectDAO.abrir();

                SqlCommand conexao = new SqlCommand("SELECT RAZãO_SOCIAL FROM BANCODEDADOSCENTRAL WHERE CNPJ = ? ", con);
                conexao.Parameters.AddWithValue("@CNPJ", SqlDbType.Int);
                conexao.Parameters["@CNPJ"].Value = toolStripTXT_Pesq_Cnpj;
                conexao.CommandType = CommandType.Text;

                SqlDataReader dr;
                dr = conexao.ExecuteReader();
                dr.Read();

                txt_razao.Text = dr.GetString(0);

        }

1 answer

0


You have to take the value of the GUI object for a simple object, you can’t be sure because you don’t have enough information on the question. It can be:

toolStripTXT_Pesq_Cnpj.Text

I put in the Github for future reference.

But then you have to do a conversion and carefully because the data can be typed wrong, see more in Differences between Parse() vs Tryparse().

There are other problems in the code, even if it works.

  • was that . text at the end. obg solved

Browser other questions tagged

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