我的ACCESS库里有一个table表,字段分别是Code,name,file,sx,mx,sy,my,area.前三个字段是字符型的,后5个字段是数字型的.我的目的是通过x,y两个值查找符合符合条件sx <x < mx,sy < y < my,并且字段Code里面的字符长度等于5,按照area排序的记录,可是按照如下写法程序出错,我调试了,就是下面的查询语句有问题.请大家帮忙看看.
doulbe x,y;
CString sql;
sql = "selece * from table where sx < x and mx > x and sy < y and my >y and Code.GetLenght()=5 and order by area";

解决方案 »

  1.   

    sql = "selece * from table where sx < x and mx > x and sy < y and my >y and Code.GetLenght()=5 and order by area";
    1.order by area前的and应该去掉吧
    2.GetLength(),Access支持这样的函数吗?因为你是将这条语句发送给Access执行,所以最好先在Access将这条语句调试通过,然后在移到VC中
      

  2.   

    第二点如何做,因为VB中可以直接写len(Code)可以通过但是在VC中如何写呢?
    另外抛开第二点不说,第一点得SX<X AND MX > X ...好像也不对,我单独只运行前面的如:
    sql = "select * from table where sx < x";也不行,但是改成如:
    sql = "select * from table where name = '001'";就可以,不知道比较double型的在SQL 语句中怎么写。
      

  3.   

    你的X是什么?
    它应该是一个变量吧,在SQL语句中不可以这么写的
      

  4.   

    可以把x转换成一个字符型的,然后
    CString a;
    a.Format("%d",x);//如果x是整型的,否则是%f
    sql = "select * from table where sx < "+a;