If I say that I need to run two separate SQL statements against two separate databases. Right now I (pseudo-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() }
The above seems very awkward. And if I have three different sql statements, I will need three different SQLCmd variables.
Is there a βstandardβ way to do such things, especially in terms of efficiency, productivity? if someone could provide a simple improved pseudo code, that would be great.
Also, do I need to worry about implementing a connection pool, saving resources and speeding up the program? If so, how to implement this in this case?
Thanks!
Saobi source share