数据库连接: try with DBWEB do begin Connected := False; DatabaseName := 'ConWEB'; LoginPrompt := False; Params.Add('SERVER NAME='+webServer); Params.Add('USER NAME='+webUID); Params.Add('PASSWORD='+webPWD); Params.Add('PORT='+webPort); DatabaseName:=webData; AliasName:='.'; LoginPrompt:=false; Connected := True; end; Result := True; except Exit; end;查询: with TQuery.Create(nil) do begin sSqlTemp:='select max(operationNo) as operationNo from '+sTableName; //从数据库中选项取最大的ID值 Close; DatabaseName := DBWEB.DatabaseName; SQL.Clear; SQL.Add(sSqlTemp); Open; if not IsEmpty then sVar:= fieldbyname('operationNo').AsString else sVar := '000000'; end;