Jump to content
randucho

Erro ao converter dados do tipo NVARCHAR em NUMERICO

Recommended Posts

randucho

sou novato em vb.net e no forum e nem sei este é o lugar certo para expor duvidas.

tenho um problema no código que estou tentar construir no visual studio com base de dado sql,

com 16 campos dos quais 8 são do tipo data e quando tento cadastrar os dados ele me retorna 

ERRO AO CONVERTER DADOS DO TIPO NVARCHAR EM NUMERICO, tentei alterar os campos no sql e não resultou.

Por falta de mais conhecimento da minha parte peço ajuda.

Btn Ad
 Try
            If Txtnatureza.Text = String.Empty Or TxtLocal.Text = String.Empty Or Txtinvoicefor.Text = String.Empty Or Txtfactura.Text = String.Empty Then

                MessageBox.Show(" Obrigatório ", "Preenchimento")
                Return

            End If
            If TxtVos.Text = String.Empty Or TxtVimp.Text = String.Empty Or Txtnos.Text = String.Empty Then

                MessageBox.Show(" Obrigatório ", "Preenchimento")
                Return
            End If

            If id <> String.Empty Then
                cn.Open()
                cm = New SqlCommand("update tblBill_itens set data=@data,nos=@nos,qtd=@qtd,punitario=@punitario,desconto=@desconto,
                                    vcontrato=@vcontrato,vpago=@vpago,adenda=@adenda,contrato=@contrato,codpip=@codpip,ncontrato=@ncontrato,
                                    vadenda=@vadenda where id=@id and invoiceno=@invoiceno", cn)
                With cm.Parameters
                    .AddWithValue("@data", DateTimePicker1OS.Value)
                    .AddWithValue("@nos", Txtnos.Text)
                    .AddWithValue("@qtd", CDbl(TxtVos.Text))
                    .AddWithValue("@punitario", CDbl(TxtVimp.Text))
                    .AddWithValue("@desconto", CDbl(Txtdesconto.Text))
                    .AddWithValue("@vpago", CDbl(TxtPago.Text))
                    .AddWithValue("@vcontrato", Txtvcontrato.Text)
                    .AddWithValue("@adenda", Dtpadenda.Value)
                    .AddWithValue("@contrato", MaskedTxtContrato.Text)
                    .AddWithValue("@codpip", TxtPip.Text)
                    .AddWithValue("@ncontrato", Txtncontrato.Text)
                    .AddWithValue("@prazo", Txtprazo.Text)
                    .AddWithValue("@vadenda", TxtVadenda.Text)
                    ' .AddWithValue("@despacho", Txtdesp.Text)
                    ' .AddWithValue("@despacho1", Dtpdesp.Value)
                    ' .AddWithValue("@abertura", Dtpabertura.Value)
                    '.AddWithValue("@carta", Txtcarta.Text)
                    ' .AddWithValue("@carta1", Dtpconv.Value)
                    ' .AddWithValue("@proposta", Dtpprosp.Value)
                    ' .AddWithValue("@relpreliminar", Dtprelpre.Value)
                    ' .AddWithValue("@final", Dtprelfinal.Value)
                    '.AddWithValue("@perctg", TxtPrctg.Text)
                    .AddWithValue("@id", id)
                    .AddWithValue("@invoiceno", Txtfactura.Text)

                End With
                cm.ExecuteNonQuery()
                cn.Close()
            Else
                cn.Open()
                cm = New SqlCommand("insert into tblBill_itens(invoiceno,data, nos,qtd,punitario,desconto,
                                vcontrato,vpago,adenda,contrato,codpip,ncontrato,prazo,vadenda
                                 )values(@invoiceno,@data,@nos,@qtd,@punitario,@desconto,@vcontrato,
                                   @vpago,@adenda,@contrato,@codpip,@ncontrato,@prazo,@vadenda)", cn)

                With cm.Parameters
                    .AddWithValue("@invoiceno", Txtfactura.Text)
                    .AddWithValue("@data", DateTimePicker1OS.Value)
                    .AddWithValue("@nos", Txtnos.Text)
                    .AddWithValue("@qtd", CDbl(TxtVos.Text))
                    .AddWithValue("@punitario", CDbl(TxtVimp.Text))
                    .AddWithValue("@desconto", CDbl(Txtdesconto.Text))
                    .AddWithValue("@vpago", TxtPago.Text)
                    .AddWithValue("@vcontrato", Txtvcontrato.Text)
                    .AddWithValue("@adenda", Dtpadenda.Value)
                    .AddWithValue("@contrato", MaskedTxtContrato.Text)
                    .AddWithValue("@codpip", TxtPip.Text)
                    .AddWithValue("@ncontrato", Txtncontrato.Text)
                    .AddWithValue("@prazo", Txtprazo.Text)
                    .AddWithValue("@vadenda", TxtVadenda.Text)
                    ' .AddWithValue("@despacho", Txtdesp.Text)
                    ' .AddWithValue("@despacho1", Dtpdesp.Value)
                    ' .AddWithValue("@abertura", Dtpabertura.Value)
                    '.AddWithValue("@carta", Txtcarta.Text)
                    ' .AddWithValue("@carta1", Dtpconv.Value)
                    '.AddWithValue("@proposta", Dtpprosp.Value)
                    '.AddWithValue("@relpreliminar", Dtprelpre.Value)
                    ' .AddWithValue("@relfinal", Dtprelfinal.Value)
                    ' .AddWithValue("@perctg", TxtPrctg.Text)
                End With
                cm.ExecuteNonQuery()
                cn.Close()

            End If
            'UpdateBill()
            Loadrecords()
            ' Limpar()
            ' CalculadoraBill()

            id = ""
        Catch ex As Exception
            cn.Close()
            MsgBox(ex.Message, vbCritical)
        End Try

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.