对于问题1:似乎应是 where 还书日期=null and 书籍编号=''''+edit2.text+''''
对于问题2:似乎应是 table1.locate('书籍编号,还书日期',vararrayof([edit2.text,'null']),[lopartialkey])
试一试吧。

解决方案 »

  1.   

    where 还书日期=null and 书籍编号='''+edit2.text+''''
    where 还书日期  is null and 书籍编号='''+edit2.text+''''is null is null
      

  2.   

    同意楼上雪莹和方恨少的意见
    不过如果觉得搞不清楚单引号的用法的话
    我推荐用下面的方式更明了一点:
    'where (还书日期 is null) and 书籍编号='+#39+edit2.text+#39
      

  3.   

      方恨少和星之瀚海的说法不对吧,如果是(where 还书日期=null and 书籍编号='''+edit2.text+'''')这样的话,那不是少了一个单引号吗?where前应该有个单引号
    吧。
      我觉的问题的关键是null的用法,即在dephi中,能不能用 null表示空字段。我运行程序
    时是提示null有问题。 请各位帮忙。
      

  4.   

    当然可以用null
    null不能引起来
    前用is 
    (还书日期 is null) 
    各个条件间就括号相隔
    还有在sql中也支持双引号
    如果觉得单引号有点乱有混
    那么就改用双吧
      

  5.   

      方恨少和星之瀚海,按你们所说,(where 还书日期=null and 书籍编号='''+edit2.text+'''')where 前不是少了一个单引号吗?
      关键是我在运行程序时,提示null出错,好象在delphi,pardox数据库中不能用null
    表示空字段,
    不知怎样解决这个查询问题?
      

  6.   

    首先回答第二个问题:你应该在该单元开始部分加入:
    uses
      .......,db(或者是adodb);第一题:(参考)
       sql.add:=('where 还书日期=null and 书籍编号='''+edit2.text+'''');
      

  7.   

    还书日期=null 是错的
    要用 还书日期 is nul 
    是少了一个单引号
    query1.sql.add('select * from fds');
    query1.sql.add('where 还书日期  is null and 书籍编号='''+edit2.text+'''');
      

  8.   

    怎样判断sql的where语句中一个字段为空记录。(' where 还书日期=null and 书籍编号='''+edit2.text+'''')错在哪里?
    改:Where 还书日期 is Null And ...
      

  9.   

    1.where 还书日期=null and 书籍编号='''+edit2.text+''''
    改成:
    where 还书日期 is null and 书籍编号='''+edit2.text+''''
    2.table1.locate('书籍编号,还书日期',vararrayof(['edit2.text','null']),[lopartialkey])。
    改成:table1.locate('书籍编号,还书日期',vararrayof([edit2.text,'null']),[lopartialkey])。
    看看是否OK!