sql1 = DTPicker1.Value
sql2 = DTPicker2.Value
sql3 = " AND 商铺号='" & Text1.Text & "'"
sql = "select count(商铺号) 'chs' from 投诉表 where 1=1" & sql3 & "and 投诉日期 > = " & sql1 & " and 投诉日期 < =" & sql2或
sql = "select 商铺号,业主,处理结果,投诉内容,备注 from 投诉表 where 1=1" & sql3 & " and 投诉日期 between " & sql1 & " and " & sql2
数据库中有符合的记录,为什么我这写查不出结果呢。
sql2 = DTPicker2.Value
sql3 = " AND 商铺号='" & Text1.Text & "'"
sql = "select count(商铺号) 'chs' from 投诉表 where 1=1" & sql3 & "and 投诉日期 > = " & sql1 & " and 投诉日期 < =" & sql2或
sql = "select 商铺号,业主,处理结果,投诉内容,备注 from 投诉表 where 1=1" & sql3 & " and 投诉日期 between " & sql1 & " and " & sql2
数据库中有符合的记录,为什么我这写查不出结果呢。
看sql语句是什么样,直接用sql工具查询,是否能查出结果
dim rs As ADODB.Recordset
Dim sql As String
dim sql1 as string
dim sql2 as string
dim sql3 as string
sql1 = DTPicker1.Value
sql2 = DTPicker2.Value
sql3 = " AND 商铺号='" & Text1.Text & "'"
sql = "select 商铺号,业主,处理结果,投诉内容,备注 from 投诉表 where 1=1" & sql3 & " and 投诉日期 between " & sql1 & " and " & sql2
Set rs = ExecuteSQL(sql).....
''''''''''''''''''''''''''''''''''''''
使用executesql要引用ado2.0以上....
sql = "select 商铺号,业主,处理结果,投诉内容,备注 from 投诉表 where 1=1 " & sql3 & " and 投诉日期 between '" & sql1 & "' and '" & sql2 & &"'"
'数据库为ACCESS:
sql = "select 商铺号,业主,处理结果,投诉内容,备注 from 投诉表 where 1=1 " & sql3 & " and 投诉日期 between #" & sql1 & "# and #" & sql2 & &"#"
'数据库为SQL:
sql = "select 商铺号,业主,处理结果,投诉内容,备注 from 投诉表 where 1=1 " & sql3 & " and 投诉日期 between '" & sql1 & " 00:00:01' and '" & sql2 & &" 23:59:59'"
'数据库为ACCESS:
sql = "select 商铺号,业主,处理结果,投诉内容,备注 from 投诉表 where 1=1 " & sql3 & " and 投诉日期 between #" & sql1 & " 00:00:01# and #" & sql2 & &" 23:59:59#"