Hi,

Currently have a working solution in displaying data from the database to listview through specific dates selected, however the problem lies with it sometimes selecting the right data for the dates and sometimes it doesn't. Just would like someone to check whether the code i have is correct or not..

If dtpSelection.Checked And dtpSelection2.Checked Then
            MyConn = New ADODB.Connection
            MyConn.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\MenuItems.mdb;")
            MyConn.Open()
            MessageBox.Show(FormatDateTime(dtpSelection.Text, DateFormat.ShortDate))
            MyRecSet = MyConn.Execute("SELECT Item_ID, ItemName, Price, Qty, Total, OrderDate FROM trans2 where OrderDate >= #" & dtpSelection.Value.ToShortDateString & "# and OrderDate <= #" & dtpSelection2.Value.ToShortDateString & "#")

            Do Until MyRecSet.EOF
                var = MyRecSet.Fields.Item("Item_ID").Value
                var2 = MyRecSet.Fields.Item("ItemName").Value 'variable2 = MyRecSet.Fields.Item("column2").Value
                var3 = MyRecSet.Fields.Item("Price").Value
                var4 = MyRecSet.Fields.Item("Qty").Value
                var5 = MyRecSet.Fields.Item("Total").Value
                var6 = MyRecSet.Fields.Item("OrderDate").Value
                ' lvItems.Clear()
                lvwItem2 = lvItems.Items.Add(var6)
                lvwItem2.SubItems.Add(var)
                lvwItem2.SubItems.Add(var2)
                lvwItem2.SubItems.Add(var3)
                lvwItem2.SubItems.Add(var4)
                lvwItem2.SubItems.Add(var5)
                ' Listbox2.AddItem(variable2)
                MyRecSet.MoveNext()
            Loop
            MyConn.Close()

nevermind ive solved it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.