我已經寫了下面的代碼之間的檢索數據:SQL查詢兩個日期
Dim date1 As Date
Dim date2 As Date
date1 = Convert.ToDateTime(DatePickerFromDate.Text)
date2 = Convert.ToDateTime(DatePickerToDate.Text)
Dim cnd As New OleDbCommand("SELECT * FROM Sales WHERE Invoice_Date BETWEEN " + date1 + " AND " + date2 + "", om)
om.Open()
Dim da As OleDbDataReader = cnd.ExecuteReader
While da.Read()
ComboBox1.Items.Add(da(0))
End While
da.Close()
om.Close()
我想那些從兩個datepickers採取兩個日期之間的檢索數據。
我試過BETWEEN,也試過> = = <但是結果是空的,儘管數據庫包含數據。請幫助我出錯的地方
這是爲什麼用MySQL和SQL Server標記的?你正在使用哪個數據庫? –