I have this code:
cnn.Open()
query = "SELECT LAST(AnnualPayments.DueDate), Members.FirstName, Members.LastName " & _
"FROM AnnualPayments INNER JOIN Members ON AnnualPayments.MemID = Members.ID " & _
"WHERE (((DateDiff('d', Now(), AnnualPayments.DueDate)) < 1)) " & _
"GROUP BY Members.FirstName, Members.LastName, AnnualPayments.DueDate " & _
"ORDER BY AnnualPayments.DueDate DESC"
cmd = New OleDbCommand(query, cnn)
Dim dt As New DataTable
ds = New DataSet
ds.Tables.Add(dt)
da = New OleDbDataAdapter(cmd)
da.Fill(dt)
Dim newRow As DataRow
For Each newRow In dt.Rows
MainForm.lstView1.Items.Add(newRow.Item(0)) 'this is for ID
MainForm.lstView1.Items(MainForm.lstView1.Items.Count - 1).SubItems.Add(newRow.Item(1)) 'this is for date
MainForm.lstView1.Items(MainForm.lstView1.Items.Count - 1).SubItems.Add(newRow.Item(2)) 'this is for firstname
Next
Catch ex As Exception
GetErrorMessage(ex)
Finally
CloseConnection()
End Try
What it's supposed to do is show only the data if the due date is more than 1 day from the date today. Can you correct my mistake please. Thanks.
Aucun commentaire:
Enregistrer un commentaire