Ho capito che non poteva andare.....
Ho provato a ciclare le righe del datatable, ma ovviamente , se imposto una variabile per memorizzare il calcolo, tiene solo l'ultimo valore che le passo....
insomma
codice:
Dim DaRicette_dett As New OleDb.OleDbDataAdapter(sqlDgv, Start.GetStrDataBase)
' creo un command builder per generare le istruzioni SQL update, insert, and delete commands sulla base di una sql (SQLDGV).
' le uso per fare l'update del database.
Dim commandBuilder As New OleDb.OleDbCommandBuilder(DaRicette_dett)
' popolo una nuova tabella e la lego al BindingSource.
Dim DTricette_dett As New DataTable()
DaRicette_dett.Fill(DTricette_dett)
bsRicette_dett.DataSource = DTricette_dett
'definisco i campi che mi servono per la colonna calcolata
Dim pquantita As Double
Dim pnPeso As Double
Dim penergia As Integer
Dim pdensita As Double
Dim pconversione As Integer
Dim pedibile As Integer
Dim i As Integer
Dim ii As Double
pquantita = DTricette_dett.Rows(i)("Qta")
pnPeso = DTricette_dett.Rows(i)("n_peso")
penergia = DTricette_dett.Rows(i)("energia kcal")
pdensita = DTricette_dett.Rows(i)("densita")
pconversione = DTricette_dett.Rows(i)("conversione")
pedibile = DTricette_dett.Rows(i)("edibile")
Dim convUsare As Double
'For Each Dr As DataRow In DTricette_dett.Rows
If pconversione > 0 Then
convUsare = pconversione
Else
convUsare = pnPeso
End If
ii = (pquantita * convUsare * penergia * pdensita * pedibile) / 10000
Next
DTricette_dett.Columns.Add("SS", GetType(Double), ii)
va un po' meglio, ma non molto....
ovviamente mi carica solo il valore dell'ultimo prodotto della mia dgv...
e non sempre... devo ancora capire la variabilià a che errore è collegabile...
Un aiutino????
Grazie