我的字段中设置的是数字类型中的长整型,但在查询语句中,
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是数字类型中的长整型。查询的时候提示表达式中的类型不对,请大家看看。
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是数字类型中的长整型。查询的时候提示表达式中的类型不对,请大家看看。
因该改成 and z_time >=" & val(txt_key) &".......
而且你代码里多了很多无用的双引号(另外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 & ""