Odd behavior using the IBM DB2 for i5/OS .NET provider dll in C# -


at company use ibm db2 i5/os .net provider dll version 12.0.7.3. in web application makes database calls iseries. encountered situation method create connection pass connection subroutines seem access wrong data sometimes. example case follows: assume server has spun up. client calls "getcontractpdf" , succeeds. client b calls same method , fails. server restarted , client b calls "getcontractpdf" method succeeds. client calls , fails.

i pulled hair out trying figure out appears code isn't disposing of or handling database connections properly. reproducible in development environment , when reproduce connection object shows right library list client used call it, after inserting test query yield data identify client database being touched absolutely getting wrong data. databases in question running on same physical as/400 machine different library lists. third client has own as/400 unaffected problem.

i have been changing method accepts connection argument create own connection , hoped won't cause big of performance hit.

here method generates connections:

  public static idb2connection getconnection(string clientcode)     {         string decrypted = "";         try         {             decrypted = system.configuration.configurationmanager.connectionstrings[clientcode].connectionstring;         }         catch (exception)         {             throw new faultexception(string.format("client connection string not found {0}.", clientcode));         }         try         {             decrypted = encryptdecrypt.decrypt(decrypted);         }         catch (exception)         {             throw new faultexception(string.format("error determining connection string client {0}.", clientcode));         }         try         {             return new idb2connection(decrypted);         }         catch (exception)         {             throw new faultexception("error accessing database.");         }     } 

and here pseudocode shows how used when problem behavior arises:

public static contractobject getcontract(clientcode,contractid){  using(idb2connection conn = getconnection(clientcode)){     contractobject contractobject = new contractobject(){       id = contractid     };     getsomedata(contractobject,conn);     getotherdata(contractobject,conn);     return contractobject;  } } public static void getsomedata(contractobject contract, idb2connection    connection){     string commandtext = "select data table conditions";     using(idb2command cmd = new idb2command(commandtext,connection)){       using(idb2datareader reader = cmd.executereader()){          if(reader.hasrows){              contract.foo = reader["columnname"].tostring();          }       }     }  }  public static void getotherdata(contractobject contract, idb2connection    connection){     string commandtext = "select data table conditions";     using(idb2command cmd = new idb2command(commandtext,connection)){       using(idb2datareader reader = cmd.executereader()){          if(reader.hasrows){              contract.bar = reader["columnname"].tostring();          }       }     }  } 

if change methods new connection object created every query behavior eliminated.

as see there 2 possible problems, either have done horribly wrong (which have), or ibm dll not handle passing around connection objects (which think less happen). i'm sure there other possibilities i'm inexperienced / code blind see.

do of have ideas of causing behavior or questions lead figuring out causes behavior?

thanks in advance time.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -