执行这个命令就出现报错
Private Sub Command6_Click()
  
  
  Adodc1.RecordSource = "select time as t,i as current,v as voltage from ssmiv where time between " & DTPicker1.Value & "and " & DTPicker2.Value & " order by time "
  Adodc1.Refresh
  Set MSChart1.DataSource = Adodc1
 ' MSChart1.TitleText = "time"
End Sub报错弹出窗口!!!
---------------------------
Adodc1
---------------------------
[MySQL][ODBC 3.51 Driver][mysqld-5.0.45-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select time as t,i as current,v as voltage from ssmiv where time between 2010-1-' at line 1
---------------------------
确定   
---------------------------

解决方案 »

  1.   

    这是FORM-LOAD,现在向数据库添加内容和在datagrid中显示都没问题,就是查询不行Private Sub Form_Load()
    cn.ConnectionString = "DSN=myodbc;"cn.Open
    sql = "select * from ssmiv"
    rs.Open sql, cn, adOpenKeyset, adLockOptimistic
    rs.AddNew'For i = 0 To Adodc1.Recordset.RecordCount - 1
           'Combo1.AddItem Adodc1.Recordset.Fields(0).Value
           'Adodc1.Recordset.MoveNext
     ' Next i
    For i = 1 To 3  'Adodc1.Recordset.RecordCount - 1
           Combo1.AddItem Adodc1.Recordset.Fields(i).Name
           Adodc1.Recordset.MoveNext
    Next iCombo1.Text = Combo1.List(1)
    End Sub
      

  2.   

    为“2010-1-”那个是DTPICKER的值,屏蔽掉还是一样报错,mysql的select语句有什么不一样吗??
      

  3.   

    Adodc1.RecordSource = "select time as t,i as current,v as voltage from ssmiv where time between #" & DTPicker1.Value & "# and  #" & DTPicker2.Value & "#  order by time "是不是要加#符号?
      

  4.   

    http://download.csdn.net/source/1644211
      

  5.   

    Dim sCmd as string
    scmd="select time as t,i as current,v as voltage from ssmiv where time between " & DTPicker1.Value & "and " & DTPicker2.Value & " order by time "
    debug.print scmd
    把SCMD拿到MySQLQueryBrowser中执行一下,看看是哪里出错了?
      

  6.   

    "select time as t,i as current,v as voltage from ssmiv where time between '" & DTPicker1.Value & "' and '" & DTPicker2.Value & "' order by time "
      

  7.   

    为什么把 Adodc1.Refresh这句屏蔽掉就不报错了??不过屏蔽掉之后程序也没有实现需要的功能!!
      

  8.   

    你把Sql语句,截取出来(在vb的立即窗口里输入?mysql),然后放到Sql查询分析器里去测试下,估计是你的sql语句的语法有问题