VB6中 报语法错误(操作符丢失)

qqww09633 2013-01-08 11:09:28
各位前辈,我想从当前表中筛选出某个时间段的数据,时间在text2和text3中,点Alarm Seach时报语法错误(操作符丢失),错误如下

代码为

Private Sub Command4_Click()
StrSQL = "select * from AlarmHistory where start time Between #" & Text2.Text & "# and #" & Text3.Text & "#"
If Rs.State <> 0 Then Rs.Close
Rs.Open StrSQL, Conn, 1, 3
If Rs.EOF Then

Else
DataGrid1.AllowUpdate = True
Timer2.Enabled = True
End If
End Sub


这个怎么解决啊??
...全文
198 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qqww09633 2013-01-09
  • 打赏
  • 举报
回复
引用 2 楼 worldy 的回复:
k看了你的表,应该是 StrSQL = "select * from AlarmHistory where [start time] Between #" & Text2.Text & "# and #" & Text3.Text & "#"
不好意思,是我自己把表的名称写错了,非常感谢worldy啊
qqww09633 2013-01-09
  • 打赏
  • 举报
回复


引用 2 楼 worldy 的回复:
k看了你的表,应该是
StrSQL = "select * from AlarmHistory where [start time] Between #" & Text2.Text & "# and #" & Text3.Text & "#"

试了一下你说的两种方法,还是会出错,是否还是其他问题啊
worldy 2013-01-08
  • 打赏
  • 举报
回复
k看了你的表,应该是 StrSQL = "select * from AlarmHistory where [start time] Between #" & Text2.Text & "# and #" & Text3.Text & "#"
worldy 2013-01-08
  • 打赏
  • 举报
回复
Private Sub Command4_Click() StrSQL = "select * from AlarmHistory where start time Between #" & Text2.Text & "# and #" & Text3.Text & "#" If Rs.State <> 0 Then Rs.Close Rs.Open StrSQL, Conn, 1, 3 If Rs.EOF Then Else DataGrid1.AllowUpdate = True Timer2.Enabled = True End If End Sub 红色部分要么是StartTime 要么应该写成:[Start Time]

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧