[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!
Re: DGV Selection Problem
You can set the Visible property of the DGV column(s) you want to hide to False.
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...