1.11M Members

Loading data into LIstView

 
0
 

I need some help with the following.

I have a form called frmMain that has a couple of icons, one of the icons when clicked loads frmNotes within a Panel, frmNotes has a ListView and i want to load data from a Microsoft Access Database Table into the ListView

I've tried with the following code however it is not working:

Imports System.Data.OleDb
Public Class frmNotes
    Public Populate As PsychologicalStateTrackerDataSet

    Private Sub frmNotes_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize

    End Sub

    Private Sub frmNotes_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'PsychologicalStateTrackerDataSet.tblNotes' table. You can move, or remove it, as needed.
        Me.TblNotesTableAdapter.Fill(Me.PsychologicalStateTrackerDataSet.tblNotes)

        For Each Note In PsychologicalStateTrackerDataSet.tblNotes

            Dim Populate As New ListViewItem

            Populate = ListViewSearch.Items.Add(Note.fldDate)

            Populate.SubItems.Add(Note.fldTime)
            Populate.SubItems.Add(Note.fldThoughts)
            Populate.SubItems.Add(Note.fldEmotions)
            Populate.SubItems.Add(Note.fldPhysicalConsequences)
            Populate.SubItems.Add(Note.fldScore)

        Next



    End Sub

End Class
Question Self-Answered as of 1 Year Ago
 
0
 

Have you set up the TblNotesTableAdapter with the necessary Access SQL command and connection
etc?

I would run in debug but before you go into the For each Note loop I'd check that PsychologicalStateTrackerDataSet.tblNotes.Rows.Count > 0 i.e. you have data.

Also what have you defined Note as? Looking at the code it should be a datarow but it looks like you have it as a class of some sort.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article