Results 1 to 3 of 3

Thread: [RESOLVED] DGV Selection Problem

  1. #1

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

    Resolved [RESOLVED] DGV Selection Problem

    Code:
    Dim Conexiune As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\***.mdb;Jet OLEDB:Database Password=****"
    
                Dim Adapter1 As New OleDbDataAdapter("SELECT nume, prenume, cnp FROM utilizatori", Conexiune)
                Dim DT1 As New DataTable("Utilizatori")
    
                Adapter1.Fill(DT1)
                dgv_cautare_utilizatori.DataSource = DT1
    
                If DT1.Rows.Count > 0 Then
    
                    Me.txt_nume.Text = DT1.Rows(0)("nume").ToString
                    Me.txt_prenume.Text = DT1.Rows(0)("prenume").ToString
                    Me.txt_cnp.Text = DT1.Rows(0)("cnp").ToString
    
                Else
                End If
    I use this code to retrieve data from my DB. It's working but i still have a problem with DataGridView (dgv_cautare_utilizatori).

    I want to display ONLY "nume" and "prenume" from the db selection not the hole selection...

    The rest of the selection i want to put it into the texboxes...

    Thanks in advice!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: DGV Selection Problem

    You can set the Visible property of the DGV column(s) you want to hide to False.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3
    Addicted Member
    Join Date
    Jun 2006
    Location
    New Orleans, LA
    Posts
    161

    Re: DGV Selection Problem

    Since your using Access and it handles the SQL strings a bit different than a SQL database would, I agree with Stanav. The easiest thing for you to do here may be to hide the columns that you do not want shown.

    Code:
    Me.DataGridView1.Columns("ExampleColumn").Visible = False
    Hope this helps...

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