0

While trying to deploy a WFA in client's machine I click this "Insertar" button and this error pops up: enter image description here

I managed to know the error is in the following line:

            con.Open();
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandType = CommandType.Text;
      -->   cmd.CommandText = "insert into [dbo].[Table] values('" + numRefInternoTxt.Text + "','" + numAsientoPrevioTxt.Text + "','" + fechaMovimientoDTP.Value.Date + "','" + fechaContableDTP.Value.Date + "','" + tipoMovimiento + "','" + infoAdicDifDeMenos + "','" + regimenFiscal + "','" + tipoOperacion + "','" + numeroOperacionTxt.Text + "','" + descripcionTxt.Text + "','" + codUnidadDeFabricacionTxt.Text + "','" + tipoJustificante + "','" + numeroJustificanteTxt.Text + "','" + tipoDocIdentificativoTxt.Text + "','" + numeroIdentificativoTxt.Text + "','" + razonSocialTxt.Text + "','" + caeTxt.Text + "','" + repTipoDocIdentificativoTxt.Text + "','" + lblRepNumDocId.Text + "','" + repRazonSocialTxt.Text + "','" + epigrafe + "','" + clave + "','" + codEpigrafe + "','" + referenciaProductoTxt.Text + "','" + codigoNCTxt.Text + "','" + densidadTxt.Text + "','" + cantidadTxt.Text + "','" + unidadDeMedida + "','" + descripcionProductoTxt.Text + "','" + gradoAlcoholicoTxt.Text + "','" + cantidadAlcoholPuroTxt.Text + "','" + numeroEnvasesTxt.Text + "','" + tipoEnvase + "','" + capacidadEnvaseTxt.Text + "','" + observacionesTxt.Text + "')";
            cmd.ExecuteNonQuery();
            con.Close();

I tried adding ".ToString()" method to the date-typed data (like this: fechaMovimientoDTP.Value.Date.ToString()) but still drops the same error.

Any clues?

Papillon
  • 1
  • 3
  • 2
    Learn to use parameters and pass the values with the correct types. – Gordon Linoff Jun 15 '20 at 01:28
  • 2
    This is an [SQL injection attack](https://shiny.rstudio.com/images/bobby-tables.png) waiting to happen, in short don't do this. Use parameterised queries that have build in support for primitive types and you will find your problem will likely go away – TheGeneral Jun 15 '20 at 01:30

0 Answers0