1 Attachment(s)
How to Import table from Access to Datagridview using VB2010 in customized format?
Hi,
I have a table in ms access. I need it to be imported to the Datagridview in vb 2010 in customized format . The below shown is my access table.
-------------------------------------------------------------
| ID | Names player | Sports |
-------------------------------------------------------------
| 1 | aleksy | rugby |
-------------------------------------------------------------
| 2 | aleksander | football |
-------------------------------------------------------------
| 3 | aleksy | hurdles |
-------------------------------------------------------------
| 4 | bazyli | Boxing |
-------------------------------------------------------------
| 5 | aleksander | car racing |
-------------------------------------------------------------
I need the output in desired format as shown in image2. Check the attachment. This should work for any number of records.
I m new to Visual basic Programming.
Your reply would be precious............
Re: How to Import table from Access to Datagridview using VB2010 in customized format
What have you actually TRIED? Post the code (with tags [see below] )'
We can probably help.
Re: How to Import table from Access to Datagridview using VB2010 in customized format
Hi,
Thanks for replying. I have listed my code which i have tried so far.
Public Class frmMainForm
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataGridView1.Rows.Add(New Object() {"aleksy", "Rugby"})
DataGridView1.Rows.Add(New Object() {"aleksander", "football"})
DataGridView1.Rows.Add(New Object() {"aleksy", "hurtles"})
DataGridView1.Rows.Add(New Object() {"bazyli", "baseball"})
DataGridView1.Rows.Add(New Object() {"aleksander", "car racing"})
DataGridView1.Rows.Add(New Object() {"bazyli", "boxing"})
DataGridView1.Rows.Add(New Object() {"bazyli", "cricket"})
DataGridView1.Rows.Add(New Object() {"grzegorz", "volleyball"})
cboNames.DataSource = _
( _
From row In DataGridView1.Rows.Cast(Of DataGridViewRow)() _
Where Not row.IsNewRow _
Select Name = CStr(row.Cells("Column1").Value) Distinct Order By Name
).ToList
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Rows = _
( _
From row In DataGridView1.Rows.Cast(Of DataGridViewRow)() _
Where Not row.IsNewRow AndAlso CStr(row.Cells("Column1").Value) = cboNames.Text _
Select Name =
CStr(row.Cells("Column1").Value),
Sport = CStr(row.Cells("Column2").Value) Order By Name).ToList
Dim f As New frmChildForm
Try
f.DataGridView1.Rows.Clear()
For Each row In Rows
f.DataGridView1.Rows.Add(New Object() {row.Name, row.Sport})
Next
f.ShowDialog()
Finally
f.Dispose()
End Try
End Sub
End Class
Please help me on this......
your reply would be much precious.
Quote:
Originally Posted by
dglienna
What have you actually TRIED? Post the code (with tags [see below] )'
We can probably help.
Re: How to Import table from Access to Datagridview using VB2010 in customized format
Edit the post, and add the CODE TAGS that you saw in the quote