如果数据表中的关键词是id。

解决方案 »

  1.   

    你是要判断某个字段为空吗 
    if ADOQuery.FieldByName('字段').IsNull then
      

  2.   

    if ADODataSet.Locate('字段名','值',[]) then
      Showmessage('找到记录');
      

  3.   

    select id from 表名 where id=id号
    返回空就不存在
      

  4.   

    //函数原型:数据定位、查找
    function TCustomADODataSet.Locate(const KeyFields: string;
      const KeyValues: Variant; Options: TLocateOptions): Boolean;
    字段名可以用关键字、任何数据库字段名,值就是具体的号码、记录(数据库记录),[]表示定位选项,默认为[]就行,
    如在表中有如下数据(表中字段名为:iId,Name):
    iId Name
    1   物品
    2   商品
    //如果找到字段iId的数据值为1的记录时,显示字段Name的记录值
    if ADODataSet.Locate('iId','1',[]) then
       ShowMessage(ADODataSet.FieldByName('Name').AsString);