prima funzione che richiama l'aggiornamento

function UpdateDataStore(e as DataGridCommandEventArgs) as boolean
dim i,j as integer
dim params(7) as string
dim strText as string
dim blnGo as boolean = true

j = 0

for i = 1 to e.Item.Cells.Count - 3
strText = Ctype(e.Item.Cells(i).Controls(0), _
TextBox).Text
if strText <> "" then
params(j) = strText
j = j + 1
else
blnGo = false
lblMessage.Text = lblMessage.Text & _
"Hai dimenticato di inserire un valore

"
end if
next

if not blnGo then
return false
exit function
end if

dim strSQL as string = "UPDATE tblUsers SET " & _
"nome = '" & params(0) & "', " & _
"cognome = '" & params(1) & "', " & _
"indirizzo = '" & params(2) & "', " & _
"citta = '" & params(3) & "', " & _
"stato = '" & params(4) & "', " & _
"zip = '" & params(5) & "', " & _
"telefono = '" & params(6) & "'" & _
" WHERE id = " & Ctype(e.Item.Cells(0). _
Controls(1), Label).Text

ExecuteStatement(strSQL)
return blnGo
end function


funzione che esegue la query

function ExecuteStatement(strSQL)
dim objCmd as new OleDbCommand(strSQL, Conn)

try
objCmd.Connection.Open()
objCmd.ExecuteNonQuery()
catch ex as Exception
lblMessage.Text = ex.Message & "Error updating the database: errore di tipo"
end try

objCmd.Connection.Close()
end function