Hi,
Why don;t you create the object in each method ?
Or if more than one class interact with the DB you could create an object
that encapsulate the DB operations. then you export methods like this:
public static void ExecuteNonScalar( OleDbCommand)
The good thing about such a design is that in one class you concentrate all
related to connections and the others DB access related issues, the classes
only need to build a Command that they pass as a parameter.
MS also has a similar architecture, take a look at it too.
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"JSheble" <js************@logicor.com> wrote in message
news:uH**************@TK2MSFTNGP12.phx.gbl...
I have a class I'm writing that has aprox 20 methods, a mixture of both
public and private. Of the private methods, 3 use a database command
object (OleDbCommand) for either inserting data or selecting data. AM I
better off making the OleDbCommand object a private field to the class, or
passing the actual object to the three methods that'll be using it?
Advantages? Disadvantages?