string strSQLtwo = "select * from hard where ComeTime between '2006-5-1' and '2006-5-31'";这句写错了
应该怎么写啊!

解决方案 »

  1.   

    a better way to use parameters in your query string, such as 
    string strSQLtwo = "select * from hard where ComeTime between @startdate and @enddate";
      

  2.   

    detail in 
    http://blog.csdn.net/knight94/archive/2006/04/15/664530.aspx
      

  3.   

    看看你的ComeTime字段是什么类型的,如果是日期的就不用加单引号了!
      

  4.   

    执行:
    string strSQL = "select * from hard where ComeTime between 2006-05-01 and 2006-05-30";
    结果是没有数据
    绑定的控件是空的
    但是没有出错string strSQL = "select * from hard where ComeTime between @2006-05-01 and @2006-05-30";
    提示至少有一个参数没有被指定
      

  5.   

    to string strSQL = "select * from hard where ComeTime between @2006-05-01 and @2006-05-30";
    提示至少有一个参数没有被指定string strSQLtwo = "select * from hard where ComeTime between @startdate and @enddate";// Set parameters with value to your DB command
    yourComm.Parameters.Add( "@startdate", yourStartDate );
    yourComm.Parameters.Add( "@enddate", yourenddate );// then execute your command
      

  6.   

    string strSQLtwo = "select * from hard where ComeTime between '2006-5-1 00:00:00' and '2006-5-31 00:00:00'";