Error creating serial numbers - "The record already exists in the table 'dbo.Linhasnumserie'. "

Asked

Viewed 68 times

-1

Good afternoon, I’m having a problem turning an ECF, when adding the serial numbers to the line. If I add only 1 it works perfectly... What I’m doing wrong?

Dim numeroserie As New GcpBENumeroSerie
Dim numerosserie As New GcpBENumerosSerie

For Each dtrow As DataRow In Session("dtNumSerie").Select("NumLinha = '" & numlinha & "'")

   numeroserie.Manual = 1
   numeroserie.Modulo = "C"
   numeroserie.NumeroSerie = dtrow("NumSerie")

   numerosserie.Insere(numeroserie)

Next

objDocCompra.Linhas(objDocCompra.Linhas.NumItens).NumerosSerie = numerosserie
  • I think it’s because of the outside instance of for put the line Dim numeroserie As New GcpBENumeroSerie within the for to be a new instance always, test!

  • 1

    Solved, thank you!

1 answer

6


Dim numerosserie As New GcpBENumerosSerie
For Each dtrow As DataRow In Session("dtNumSerie").Select("NumLinha = '" & numlinha & "'")
   Dim numeroserie As New GcpBENumeroSerie
   numeroserie.Manual = 1
   numeroserie.Modulo = "C"
   numeroserie.NumeroSerie = dtrow("NumSerie")
   numerosserie.Insere(numeroserie)
Next
objDocCompra.Linhas(objDocCompra.Linhas.NumItens).NumerosSerie = numerosserie

Browser other questions tagged

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