title: What is the best way to handle multiple database connections in C#
body: <p>If say I need to run two separate SQL statements against two separate databases. Right now I do (pseudocode):</p>
  
  <pre><code>Try{
  
  declare variable connectionA to DatabaseA 
  declare variable connectionB to DatabaseB 
  
  connectionA.open()
  connectionB.open() 
  
  
  declare variable SQLCmdA with ConnectionA and one SQL statement 
  declare variable SQLCmdB with ConnectionB and another SQL statement 
  
  SQLCmdA.executeNonQuery() 
  SQLCmdB.executeNonQuery()
  
  }
  
  Catch () 
  {
     print error message
  }
  
  Finally(){ 
    connectionA.close() 
    connectionB.close()
    SQLCmdA.Dispose()
    SQLCmdB.Dispose() 
  } 
  </code></pre>
  
  <p>The above seems very clumsy. And if I have three different sql statements, i would need three different SQLCmd variables.</p>
  
  <p>Is there a "standard" way of doing such things, especially in terms of efficiency, performance? if anyone can provide a simple improved pseudocode, that'd be great. </p>
  
  <p>In addition, do I need to worry about implementing Connection Pooling, to conserve resource and speed up the program? If so, how do I implement it in this case?</p>
  
  <p>Thanks!</p>