Dear firends,
I want to put the value "Da" to all the Cells of the CurrentRow where the "Cell(5).Value=SOMETHING" and the "ColumnHeaderText=SOMETHING" it's found.
Code:For Each rand As DataGridViewRow In Me.dgv_lista_repere.Rows For Each coloana As DataGridViewColumn In dgv_lista_repere.Columns Try conectare_db() Dim rezultat As String = "SELECT lista_indicatori_cursanti.cnp, nomenclator_indicatori.denumire FROM lista_indicatori_cursanti, nomenclator_indicatori WHERE nomenclator_indicatori.denumire=(SELECT nomenclator_indicatori.denumire FROM nomenclator_indicatori WHERE nomenclator_indicatori.id=lista_indicatori_cursanti.id_indicator AND lista_indicatori_cursanti.cnp='" & rand.Cells(5).Value & "');" command_exec = New SqlClient.SqlCommand(rezultat, conexiune) data_reader = command_exec.ExecuteReader If (data_reader.Read = True) Then Dim cnp_cursant As String = data_reader(0) Dim denumire_indicator As String = data_reader(1) If rand.Cells(5).Value = cnp_cursant AndAlso coloana.HeaderText = denumire_indicator Then rand.Cells(coloana.Index).Value = "Da" End If Else End If deconectare_db() Catch ex As Exception deconectare_db() MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try Next coloana Next rand




Reply With Quote