当存储过程中返回值为nil时,如何避免出错?
with ADOCommand1 do
    begin
      Parameters.ParamByName('@用户名').Value:=combobox1.Text ;
      Execute ;
      try
        label4.Caption:=Parameters.ParamByName('@密码').Value;
        //此句,若返回@密码为空值时系统会出错,如何解决?
      except        
        label4.Caption:='';
      end;
    end;

解决方案 »

  1.   

    改一下:
    with ADOCommand1 do
        begin
          Parameters.ParamByName('@用户名').Value:=combobox1.Text ;
          Execute ;
          if Parameters.ParamByName('@密码').Value<>null then 
            label4.Caption:=Parameters.ParamByName('@密码').Value
          else
            label4.Caption:='';
        end;
      

  2.   

    with ADOCommand1 do
        begin
          Parameters.ParamByName('@用户名').Value:=combobox1.Text ;
          Execute ;
            label4.Caption:=VarToStr(Parameters.ParamByName('@密码').Value);
            //此句,若返回@密码为空值时系统会出错,如何解决?
        end;