Aggiorna il campo nome, cognome nella tabella Anagrafica dove lo stato è........
Esito ritorna True se viene aggiornato almeno un record.
codice:
Function ModificaUtente(ByVal nome As String, ByVal cognome As String, ByVal stato As String)
Dim objConnection As New SqlConnection("server=mioServer;database=mioDatabase;user=mioUser;password=miaPassword;Timeout=5")
Dim objcommand As New SqlCommand
objcommand.Connection = objConnection
objcommand.CommandType = CommandType.Text
objcommand.Parameters.AddWithValue("@nome", nome)
objcommand.Parameters.AddWithValue("@cognome", cognome)
objcommand.Parameters.AddWithValue("@stato", stato)
objcommand.CommandText = "UPDATE Anagrafica SET nome=@nome, cognome=@cognome WHERE stato=@stato"
objConnection.Open()
Dim esito As Boolean = CType(objcommand.ExecuteNonQuery(), Boolean)
objConnection.Close()
objcommand = Nothing
objConnection = Nothing
Return esito
End Function