Dim CheckMonth as String=session("C_Month")
Dim CheckMail as String=session("C_Mail")
Dim CheckMonths as String=CheckMonth+"01"
Dim CheckMonthe as String=CheckMonth+"31" Dim StrConnString as String="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.mappath("database/clientdatabase/FaxQuery.asp")
    Dim objConn as new oledbConnection(StrConnString)
Dim StrSql as String="Select * from AccountHistory where (account='"&CheckMail&"') and (refNo between "&CheckMonths&" and "&CheckMonthe&")"
Dim objCmd as new oledbCommand(StrSql,objConn)CheckMonth是200506,Sql语句总是出错!

解决方案 »

  1.   

    refNo 如果是日期型就要错误了
    ================================================================
    此帖通过csdn小助手回复。
        CSDN小助手是使用vb.net编写的CSDN论坛脱机“外挂”,她能够在
    脱离IE的情况下使用Csdn论坛。程序只加载最核心的数据,所以显示更
    快,产生的流量更小。    下载地址:http://qqwwee.com/csdn.rar
    ================================================================
      

  2.   

    refNo 在数据库里是int 类型
      

  3.   

    如果refNo的确是字符型的,应该加上单引号:
    Dim StrSql as String="Select * from AccountHistory where (account='"&CheckMail&"') and (refNo between '"&CheckMonths&"' and '"&CheckMonthe&"')"
      

  4.   

    加单引号也不对,都去掉也不对,我是不是应该把CheckMonth换成整型?怎么换?
      

  5.   

    将where后面的用括号括起来试试
      

  6.   

    这句应该是这样的:
    Dim StrSql as String="Select * from AccountHistory where( (account='"&CheckMail&"') and (refNo between "&CheckMonths&" and "&CheckMonthe&"))"
      

  7.   

    Dim StrSql as String="Select * from AccountHistory where (account='"&CheckMail&"') and (refNo between "&CheckMonths&" and "&CheckMonthe&")"
    把上面这一句,用
    response.write(strsql)
    response.end();
    打印出来,看看是否正确.
    另外,你这个CheckMonthe是否正确的日期呢?它是否如:2005-1-1这样的日期呢?
    还有,你是ACCESS数据库,它必须在参数前后加#(日期型)
    所以你的语句必须类似如下才可以
    sql = "select * from table where sdate between #2001-1-1# and #2001-5-1#"
    这样才是正确的.
      

  8.   

    refNo 在数据库里是int 类型怎么可以和 日期去比较?????
      

  9.   

    关键是就是执行的这一句就出错了,
    我也想输出看一个可根本就执行不到这一句Response.write 就说需要语句结束!我的数据库里是int 型如20050601而我的CheckMonth只是200506所以要加01再加个31是让他选这个期间的
      

  10.   

    所以我在说是不是应该把CheckMonths换成int 型,关键是怎么换才行
      

  11.   

    Dim StrSql as String="Select * from AccountHistory where (account='"+CheckMail+"') and (refNo between "+CheckMonths+" and "+CheckMonthe+")"
    我试过这个可以