Adodc1.RecordSource = "select Instore.ProId as 产品编号,ProName as 产品名称,Quantity as 数量,Hand as 经手人,InstoreCode as 票号,Instore.Indate as 日期 From Instore Join  Product on dbo.Instore.ProId=dbo.Product.ProId where Instore.Indate between " + Str(DTP1.Value) + Chr(37) + "and " + Str(DTP2.Value) + Chr(37) + ""提示:关键字‘and’附近错误
我看语法好象没错,其它地方请大家帮我看看`

解决方案 »

  1.   

    DTP1.Value    是DTPicker控件 
    日期控件
      

  2.   

    between  and 没写对:改为:
    ...... where Instore.Indate between '" + Str(DTP1.Value) + "' and '" + Str(DTP2.Value) + "'"
      

  3.   

    Str(DTP1.Value)=“2006-3-8”
    但数据库里存的是2006-3-8 00:00:00 000
    这怎么写呢?
    Str(DTP1.Value) + Chr(37) 我意思日期后面加个%
      

  4.   

    没办法,把数据库datetime  改成varchar
    刚才那样提示:数据转换错误
      

  5.   

    在sql库里,2006-3-8 00:00:00.000被认为=2006-3-8,你可以在查询分析器里测试,看结果
      

  6.   

    datetime  改成varchar,底下就执行成功了字段还是datetime 怎么写呢?如还是底下,就提示转换错误where Instore.Indate between  '" + Str(DTP1.Value) + Chr(37) + " 'And '" + Str(DTP2.Value) + Chr(37) + " '"
      

  7.   

    convert(varchar(10), 字段,111 )