将日期和/或时间转换为字符串时,转换失败

时间:2020-06-15 01:27:49

标签: c# sql

在尝试在客户端计算机上部署WFA时,我单击此“插入”按钮,并弹出此错误:enter image description here

我设法知道错误在以下行:

            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();

我尝试将“ .ToString()”方法添加到日期类型的数据中(例如:fechaMovimientoDTP.Value.Date.ToString()),但仍然会删除相同的错误。

有任何线索吗?

0 个答案:

没有答案