This code is supposed to populate a list with values from a table but the list keeps on being empty.Code:Public Function popdrawschedules() Dim cmd As New OleDbCommand Dim db As New dbconnection cmd.Connection = db.connection 'Dim todate As Date = Now.ToShortDateString cmd.CommandText = "select drawcode,typecode,drawtime from drawschedules where drawdate >= to_date(to_char(current_date),'mm-dd-yy')" 'cmd.Parameters.AddWithValue("", todate) Dim i As Integer = 0 Dim list As New List(Of String) Dim list2 As New List(Of String) Dim list3 As New List(Of String) Dim dr As OleDbDataReader Dim found As Boolean = False dr = cmd.ExecuteReader While dr.Read found = True list(i) = dr("drawcode") list2(i) = dr("typecode") list3(i) = dr("drawtime") i = i + 1 'ReDim Preserve arr(i) End While Dim cummList As New List(Of String) For k As Integer = 0 To list.Count - 1 cummList(k) = list(k) & " " & list2(k) & " " & list3(k) k = k + 1 Next cmd.Dispose() dr.Close() Return cummList End Function Private Sub CheckDraw_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim ds As New drawschedules Dim found As Boolean = ds.checkdrawschedules If found = True Then Panel1.Visible = True Me.lstTypeName.Items.Clear() Me.lstTypeName.Items.AddRange(ds.popdrawschedules()) Else Me.lblMessage.Visible = True End If End Sub
Ps: I'm new to vb.net so please help me figure this out pronto.


Reply With Quote
