Hi, can anyone tell me whether im storing my data into list<of T> correctly? My codes are as follows:

  Dim connect As String
        connect = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & Application.StartupPath & "\segdata.accdb"
        Dim conn As New OleDbConnection(connect)
        Dim cmd As OleDbCommand = New OleDbCommand
        cmd.Connection = conn
        cmd.CommandText = "SELECT DISTINCT AdminNo, ModuleCode FROM(SEGDATA)ORDER BY AdminNo ASC, ModuleCode ASC"
        Dim dt1 As New DataTable
        cmd.CommandText = "SELECT DISTINCT PaperNo,ModuleCode1,ModuleCode2,ModuleCode3, ModuleCode4, ModuleCode5, ModuleCode6, ModuleCode7, ModuleCode8, ModuleCode9 FROM(PapersList)ORDER BY PaperNo ASC"
        Dim dt2 As New DataTable
        'store retrieved modulecode in empty string
        Dim curmodulecode As String = String.Empty
        DataGridView1.AutoGenerateColumns = True
        DataGridView1.DataSource = dt1
        DataGridView2.AutoGenerateColumns = True
        DataGridView2.DataSource = dt2
        'loop first query
        For i As Integer = 0 To dt1.Rows.Count - 1
            Dim j As Integer
            'check if there is modulecode exist, if not, add in
            If DataGridView1.Rows(i).Cells(j).Value Is Nothing Then
                DataGridView1.Rows(i).Cells(j).Value = curmodulecode
                i = i + 1
            End If
            'Dim x, y As Integer
            'loop through query 2
            Dim MCs As String = String.Empty
            For z As Integer = 0 To dt2.Rows.Count - 1
                Dim y As Integer
                'check if curmodule is found in each row
                If DataGridView2.Rows(z).Cells(y).Value Is Nothing Then
                    DataGridView2.Rows(z).Cells(y).Value = MCs
                End If
                ' store PaperNo, Modulecodes, Students in list(of T)
                Dim mylist As New List(Of Object)


If you know the type of data that is being stored in the datagridviews, just simply declare that type of list:

    'If Data is a String
 Dim myList As New List(Of String)
    'If Data is a integer
 Dim myList As New List(Of Integer)


Then enumerate through the list!

For Each s As String in myList
    'Do Work

For Each i As Integer in myList
    'Do Work

Edited 3 Years Ago by Begginnerdev

When I'm writing the words in my text box it seems impossible to get the word showing on the document. Im using c#. Can someone help me please.

You will have to post a new question in the C# forums.
This is a vb.net forum.

The Daniweb rules also state that you can not thread hijack. So, please don't do this.

You can read the rules HERE.

Edited 3 Years Ago by Begginnerdev

This article has been dead for over six months. Start a new discussion instead.