Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combine Xml format with sql results

Status
Not open for further replies.

ehx6

IS-IT--Management
May 20, 2004
150
US
hi, I am quering two servers
server one get me data in xml format and server two get me data in datareader format(recordset)

How can I combine both return into a single aspx page that display the return data in a single view. (by the way, there are an amount from both sources that I also need to combine into total payment.

thanks for your help
Ehx
 
What I suggest to you is to make a common ancestor to your 2 return types. this ancestor, that we'll call "Query" sould have this kind of getters :
Code:
   public String getString(String dataName)
   public int getInt(String dataName)
   public Date getDate(String dataName)
Where dataName is the name of a column.

Then, build an adapter that will execute your queries, and should translate any queryresult format into a couple of getters. In a pseudo-java syntax, this should give something like this :
Code:
public class QueryAdapter {
   private Hashmap queries = null;

   /* constructor */
   public QueryAdapter() {
     queries = new HashMap();
   }

   /* queryBuider */
   public boolean buildQuery(
                      String id,
                      String resultType,
                      String Sql,
                      Connection dbConnect) {
      /* buid query and return false if failed */
      /* Query myQuery = new RecordsetReturnQuery (...)
      or
         Query myQuery = new XMLReturnQuery (...)
      ... */

      /* add query to hashmap */
      queries.put(id, myQuery);
   }
   
   /* string getter */
   public String getString(
                      String queryId, 
                      String dataName) {
      if (queries.containsKey(queryId) {
          return ((Query)queries.get(queryId)).getString(dataName);
      }

      /* do the same way for other getters */
}
This way, the only interface your web pages should have is the adapter, call it without wondering the result format type.

Hope that helps.

Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top