How to Import table from Access to Datagridview using VB2010 in customized format?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: How to Import table from Access to Datagridview using VB2010 in customized format?

  1. #1
    Join Date
    Apr 2012
    Posts
    6

    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............
    Attached Images Attached Images  

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,961

    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] )'
    Code:
    ' This is CODE
    We can probably help.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Apr 2012
    Posts
    6

    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 View Post
    What have you actually TRIED? Post the code (with tags [see below] )'
    Code:
    ' This is CODE
    We can probably help.

  4. #4
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,961

    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
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center