I'm having a data conversion problem when it passes For Each
, it says that "vl_maodeobra"
can not be converted from String to Integer
type. The problem is that no matter the conversion I try to make the same error, just changing the message, for example: can not be converted from String
to Double
or Decimal.
The "vl_maodeobra"
item returns numbers with commas, decimals, and Query below returns the data correctly. The error only appears when it passes the line vl_mo_total += mObra.Rows("vl_maodeobra").ToString()
.
I'm trying to add the value of the workforce for each line that returns from the query .
SB = New System.Text.StringBuilder
SB.Append(" Select a.vl_maodeobra ")
SB.Append(" from garantia a ")
SB.Append(" where a.dt_exclusao is null ")
SB.Append(" and a.dt_inclusao >= to_date('01/01/2013', 'dd/mm/yyyy') ")
SB.Append(" and a.cd_laudo = 21 ")
SB.Append(" and cd_tipo_garantia <> 'C' ")
SB.Append(" and a.vl_total > 0 ")
SB.Append(" and a.nu_lote = " & LO.ToString & " ")
SB.Append(" and a.cd_concessionario = 5 ")
Dim mObra As DataTable = DB.CreateDataTable(SB.ToString)
If mObra.Rows.Count >= 1 Then
Dim vl_mo_total As Double = 0
For Each currow2 As DataRow In mObra.Rows
vl_mo_total += mObra.Rows("vl_maodeobra").ToString()
Next