我正在尝试创建一个系统,其中将显示一个表单,通知用户产品还有一个月到期,这就是我所在的位置,
    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当我尝试调试它时,我的列表视图中没有显示任何内容,尽管应该有。我是vb的新手,我不确定我的“命令文本”语法是否正确。
发布于 2018-03-10 11:03:12
我已经能够通过改变语法来解决我的问题。
    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)谢谢你的意见...
https://stackoverflow.com/questions/49200557
复制相似问题