Using C# in a windows form, the code snippet below works, but looks very ineffecient to me. I created 2 pairs of objects to do 2 separate but similar tasks (conn & conn1, cmd & cmd1 etc).
It seems like I should be able to reuse conn, and perhaps cmd, but I am not sure what I need to release, reset, etc. I have been running into a host of errors.
What would be an effecient way to reorganize this code?
Many thanks, Mike Thomas
// set up stored proc | | M Thomas | | Have both commands use the same connection object. Unless you need to read data from two commands concurrently (i.e., read some data from one command, then the other, then from the first again), you only need one connection. Connections are pooled anyway, so having more than one isn't all that expensive. You can reuse command objects too, but its usually not worth the trouble. | | Nimrand |
|