我有一个SQL语句,我试图用来将vb.net程序连接到访问数据库。我用日期/时间选择器来提供日期。我已经四处搜索,我对声明所做的各种更改都没有返回任何结果。对于这个查询在访问中可以正常工作的价值:
SELECT * FROM tblcallLog
WHERE startDate Between #" & dspstart.text & "# AND #" & dtpend.text & "#"
根据@ ajax81的请求,这里是整个点击事件
在这里输入代码
Private Sub btnDateUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDateUpdate.Click
grpT2DateRange.Visible = True
grpT2SingleStaff.Visible = True
grpT2Transfer.Visible = True
lblT2TotalCallsData.Visible = True
Dim strSDate As String = dtpStart.Text
Dim strEDate As String = dtpEnd.Text
'CountDate Variables
Dim strSQLCountDate As String = _
"SELECT * FROM tblcallLog WHERE startDate Between #" & dtpStart.Text & "# AND #" & dtpEnd.Text & "#"
Dim odaCallDate As New OleDb.OleDbDataAdapter(strSQLCountDate, strPath)
Dim datCallDateCount As New DataTable
Dim intDateCount As Integer
intDateCount = datCallDateCount.Rows.Count
lblT2TotalCallsData.Text = intDateCount.ToString
enter code here
答案 0 :(得分:0)
编辑: 我刚刚注意到的另一个小问题 - 用于语句之间的日期字段id往往以相同的首字母缩写为前缀。你确定你引用了正确的字段吗? (你有dspStart和dtpEnd ......)