some of rows missing the calculation why?

  • Thread starter Thread starter Houssem12
  • Start date Start date
H

Houssem12

Guest
HI members

i have table "ARTSTOCK' in database

when i execute my code all rows work perfectly when it reach some row don't

i looked a lot for a solution with no result

so please help

Dim dll As New SqlCommand("select AR_Ref,Qte from DL_Ligne_Table where Numero='" & numero & "' order by numseq ", cn)
Dim att As New SqlDataAdapter(dll)
Dim arttab As New DataTable
att.Fill(arttab)

For k = 0 To arttab.Rows.Count - 1

Dim art As New SqlCommand("select AS_QteCom from F_artstock where ar_ref='" & arttab.Rows(k).Item(0) & "' and DE_NO='1'", cn)
Dim Qte As Double = art.ExecuteScalar
Dim totQte As Double

totQte = Qte - CDbl(arttab.Rows(k).Item(1))

If totQte < 0 Then

Dim comart As New SqlCommand("update F_artstock set AS_QteCom='0' where ar_ref='" & arttab.Rows(k).Item(0) & "' and DE_NO='1'", cn)
comart.ExecuteNonQuery()
Else

Dim comart As New SqlCommand("update F_artstock set AS_QteCom='" & totQte & "' where ar_ref='" & arttab.Rows(k).Item(0) & "' and DE_NO='1'", cn)
comart.ExecuteNonQuery()


End If





Next


the code execute like

when i enter a table with 4 column

i make the 3rd column as qte

it take the qte exist in artstock and make it minus the entered one

after all thing work unless in some rows don't

please help

Continue reading...
 
Back
Top