Get the last 2 moths data from access database table


i have this code for get the last 2 moth of data from access data base to list view in, but this give me error

this is my code:

Public Sub showlistview()
        Dim dt As New DataTable
        Dim ds As New DataSet
    Dim da As New OleDbDataAdapter("SELECT * FROM pay_pretalk _
                                   WHERE sdate > DATE_SUB(now(), INTERVAL 2 MONTH)", con)
        Dim myrow As DataRow
        For Each myrow In dt.Rows
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(3))
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(4))
            ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(5))
        ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(6))
        ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(myrow.Item(7))
End Sub

and this is the error:

IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

how can i do this.
asked on Stack Overflow May 2, 2016 by Noor Phone • edited Jul 6, 2020 by Martijn Pieters

1 Answer

            dim ds as new DataSet();
            dim adapter as new OleDataDataAdapter("SELECT * FROM pay_pretalk                                             

            WHERE sdate > DateAdd("m", -2, Date())", con);
            dt = ds.Tables[0];


answered on Stack Overflow May 2, 2016 by Michael Rudner Evanchik • edited May 3, 2016 by Michael Rudner Evanchik

User contributions licensed under CC BY-SA 3.0