Results 1 to 6 of 6

Thread: DataGridView and SQL Selection

Threaded View

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    DataGridView and SQL Selection

    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
    Last edited by Alexandru_mbm; Apr 17th, 2011 at 05:34 PM.
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width