Quella che segue è la funzione che uso allo scopo sopra indicato.
codice:
Function incr_decr_Aree(toDo As String, listaAree As String) As Boolean
Dim theQuery As String
Select Case toDo
Case "incr": 'incrementa
theQuery = "UPDATE frutta SET quantita = (quantita + 1) WHERE frutto IN ('"
theQuery += listaAree.Replace(",", "', '")
theQuery += "')"
Case "decr": ' decrementa
' query in costruzione
End Select
Dim areeCmd As new oleDbCommand(theQuery, Con)
Try
Con.Open()
Dim confirm As Integer
confirm = areeCmd.ExecuteNonQuery()
Con.Close()
If confirm > 0 Then
Return True
Else
Return False
End If
Catch
End Try
End Function
Il primo parametro indica quale query utilizzare.
Per ora sto testando la prima: "incr"
Il secondo parametro (listaAree) rileva il risultato di una checkboxList, che ovviamente è del tipo: mela, pera, arancia ecc.
Ho anche provato con un response write a stapare la query, ed è corretta! Ricevo cioè un risultato come questo
codice:
UPDATE frutta SET quantita = (quantita + 1) WHERE frutto IN ('mela', 'pera', 'arancia')
ma come al solito viene aggiornato solo il record corrispondente al primo elemento, in questo caso 'mela'.
Ci sto diventando matto. Anch'io non capisco come sia possibile.
Grazie ragazzi.