procedure TfrmMain.Button1Click(Sender: TObject); var MyLogisticsCompanyApi: TLogisticsCompanyApi; begin MyLogisticsCompanyApi := TLogisticsCompanyApi.Create; try ShowMessage(MyLogisticsCompanyApi.GetCompanyCodeListStr); finally MyLogisticsCompanyApi.Free; end; end;
function TLogisticsCompanyApi.GetCompanyCodeListStr: string; var MyFqApi: TFqApi; MyList: TStringList; begin MyFqApi := TFqApi.Create(nil); MyList := TStringList.Create; try MyFqApi.Connection := frmClientDm.MyMainCon; with MyFqApi do begin SQL.Text := 'SELECT top_company_code FROM top_logistics_company ORDER BY top_company_precedence'; Open; end; if not MyFqApi.IsEmpty then begin //去除重复,不sort就无效 MyList.Duplicates := dupIgnore; while not MyFqApi.Eof do begin MyList.Add(MyFqApi.FieldByName('top_company_code').AsString); MyFqApi.Next; end; //返回数据 Exit(MyList.CommaText); end else begin //说明为空,返回异常 Exit(''); end; finally MyFqApi.Free; MyList.Free; end; end;

本文来自博客园,作者:del88,转载请注明原文链接:https://www.cnblogs.com/del88/p/3682609.html
浙公网安备 33010602011771号