小弟最近在做超是的管理程序,有一问题向众高手请教,比如:我现在要将
条码为1000的商品价格查出并将其付给一个变量,该如何处理。

解决方案 »

  1.   

    function GetPrice(const ABarCode: string): string;
    const
      SQL = 'select 商品价格 from 表' + 
            'where 条码 = :fBarCode';
    begin
      dstGetPrice.Active := False
      
      dstGetPrice.CommentText := SQL;
      dstGetPrice.Parameters.ParamByName('fBarCode').Value := ABarCode;
      
      dstGetPrice.Open;
      Result := dstGetPrice.FieldByName(fPrice).AsString;
    end;edtPrice.Text := GetPrice(edtBarCode.Text);
      

  2.   

    with query1 do
    begin
      close;
      sql.clear;
      sql.add('select * from tableprice where priceid=''1000''');
      if prepared=False then Prepare;
      open;
    end;
    Sprice:=query1.fieldbyname('priceid').Asstring;