我的字段中设置的是数字类型中的长整型,但在查询语句中,
StrQry3 = "select Z_Time,M_date,id from TDS_Real_Data where datevalue(M_date)= '" & Load_date & "'" & "and Z_Time >='" & Txt_key.Text & "'" & " and Z_Time<='" & Txt_key2.Text & "'"Txt_key和Txt_key2是2个文本框,我就是要查这2个数据之间的数据。Z_time是数字类型中的长整型。查询的时候提示表达式中的类型不对,请大家看看。

解决方案 »

  1.   

    StrQry3 = "select Z_Time,M_date,id from TDS_Real_Data where datevalue(M_date)= '" & Load_date & "'" & "and Z_Time between " & Txt_key.Text & " and " & Txt_key2.Text 
      

  2.   

    Z_Time 是长整型,就不用加引号了。...."and Z_Time >=" & Txt_key.Text & " and "....
      

  3.   

    ...."and Z_Time >=" & Txt_key.Text & " and "....
    因该改成 and z_time >=" & val(txt_key) &".......
      

  4.   

    长整型不能加单引号,加单引号表示字符型,应该改为:
    而且你代码里多了很多无用的双引号(另外M_date是什么类型,如果是数字型也要去单引号)
    StrQry3 = "select Z_Time,M_date,id from TDS_Real_Data where datevalue(M_date)= '" & Load_date & "' and Z_Time >=" & Txt_key.Text & " and Z_Time<=" & Txt_key2.Text & ""
      

  5.   

    因该改成 and z_time >=" & val(txt_key) &".......==============哈哈,val()是多此一举,搞不好还会出错。