想查询表中日期介于*与*之间的数据,代码如下
OdbcDataAdapter da = new OdbcDataAdapter("select *  from inware where 操作时间 between " +textBox1.Text + " and "+textBox2.Text+"", odbccon);
操作时间 数据类型为datetime(8)
textBox1.text为2009-5-1
textBox2.text为2009-5-30
该如何写?

解决方案 »

  1.   

    OdbcDataAdapter da = new OdbcDataAdapter("select *  from inware where 操作时间 between '2009-5-1' and '2009-5-30'", odbccon)
      

  2.   

    我的日期是从textBox动态获取的啊,用单引号括?
      

  3.   

    --这样,日期两边要加上'OdbcDataAdapter da = new OdbcDataAdapter("select *  from inware where 操作时间 between '" +textBox1.Text + "' and '"+textBox2.Text+"'", odbccon);
      

  4.   

    OdbcDataAdapter da = new OdbcDataAdapter("select *  from inware where 操作时间 between " + "'" + textBox1.Text.trim() +"'" + " and " + "'" +textBox2.Text.trim()+ "'" + "", odbccon); 这样就OK了。
      

  5.   

    OdbcDataAdapter da = new OdbcDataAdapter("select *  from inware where 操作时间 between " + "'" + textBox1.Text.trim() +"'" + " and " + "'" +textBox2.Text.trim()+ "'" + "", odbccon);