源代码:
procedure Tselect.Button2Click(Sender: TObject);
var
  depart,age,sex,province,sqlstr:string;
begin
  if cs_depart.text='选择' then
  depart:=''
  // 未限定系
  else depart:='部门='+quotedstr(cs_depart.Text);
  if cs_sex.text='选择' then
  sex:=''
  //未限定性别
  else sex:='性别='+quotedstr(cs_sex.Text);
  {if (cs_age.text='选择') or (edt_age.text='') then
  age:=''
  //未限定年龄
   else if cs_age.text='大于' then
   age:='年龄>'+edt_age.text
   else if cs_age.text='等于' then
   age:='年龄='+edt_age.text
   else if cs_age.text='小于' then
   age:='年龄<'+edt_age.text
   else age:='';
   if cs_province.text<>'' then
   province:='province='+quotedstr(cs_province.Text)
   else province:='';}
   //未限定省份   with query1 do
   begin
     close;
     sql.clear;
     sqlstr:='select * from basic';   if depart<>'' then
      begin
         sqlstr:=sqlstr+'where'+depart;
         if sex<>'' then sqlstr:=sqlstr+'and'+sex;
         if age<>'' then sqlstr:=sqlstr+'and'+age;
         if province<>'' then sqlstr:=sqlstr+'and'+province;
      end
   else begin
          if sex<>'' then
          begin
            sqlstr:=sqlstr+'where'+sex;
            if age<>'' then sqlstr:=sqlstr+'and'+age;
            if province<>'' then sqlstr:=sqlstr+'and'+province;
          end
   else begin
        if age<>'' then
          begin
          sqlstr:=sqlstr+'where'+age;
          if province<>'' then sqlstr:=sqlstr+'and'+province;
          end
        else begin
        if province<>'' then
          sqlstr:=sqlstr+'where'+province;
        end;
   end;
  end;
  Query1.SQL.Text:=sqlstr;
  Query1.ExecSQL;
 end;
 dbgrid1.Refresh;
 query1.Active:=true;
  {sql.Text:=sqlstr;
  try
   prepare;
   open;
   except
    showmessage('访问数据库出错!');
    exit;
   end;
   end;}end;
出错信息:
Project Project1.exe raised exception class EDBEngineError with message 'Invaild user of keyword
Token:='男'
line Number:1'.process stopped. Use Step or Run to continue.