I'm trying to create a system where there will be a form showing up to notify the user that the products that has a month left to be expired, and here's where I am,
Dim dtdate As Date
dtdate = Now
Dim commanddText As String = "SELECT * FROM tblDrugs WHERE ExpiryDate - 30 <= @ExpiryDate"
Dim commandd As OleDbCommand = New OleDbCommand(commanddText, connection)
commandd.Parameters.AddWithValue("@ExpiryDate", dtdate)
Dim reader As OleDbDataReader = command.ExecuteReader
ListView1.Items.Clear()
If reader.HasRows Then 'When there's a product that satisfies the condition, I put them in a listbox
While reader.Read
Dim search() As String = {reader(1).ToString, reader(2).ToString, reader(3).ToString, reader(7).ToString}
Dim DrugsRecord As ListViewItem = New ListViewItem(search)
ListView1.Items.Add(DrugsRecord)
End While
When I try to debug it there's nothing showing in my listview even though there should be. I'm new to vb and I'm not sure if my syntax for "commanddtext" is right.
答案 0 :(得分:0)
我已经能够通过更改语法来解决我的问题。
Dim dtdate As Date
dtdate = Now.AddMonths(1).Date
Dim commandText As String = "SELECT * FROM tblDrugs WHERE ExpiryDate < @ExpiryDatee"
Dim command As OleDbCommand = New OleDbCommand(commandText, connection)
command.Parameters.AddWithValue("@ExpiryDatee", dtdate)
感谢您的意见......