I am trying to get my database connection sorted out - i can create the conenction and all works fine but I will need to connect to the databse from a number of files and don't want to have to keep copying the code so I am trying to move my connection code into a class and have the other classes call it - not sure if this will technically work. Would it be easier to go with a connection pool? Anyway this is what I ahve so far - both parts sort of work but i can't get them to talk to each other Connection Code
In what seems to be the constructor for the Connect class, you are doing this: return connection First of all, a constructor should not be returning a value bacause it implicitly returns a reference "this" to the class. In your TableDisplay class, this Connect.Connect(); is actually a method call. Bottom line is you should be returning the collection object from within a method. And all this compiled?
Bosun (SCJP, SCWCD).
So much trouble in the world -- Bob Marley
Hi, Thanks for your pointers, I now understand why it doesn't work but am a bit unclear as to how to get it working. Firstly should I be creating this connection class at all? secondly what do I do to the connection class to allow the other classes to request and receive a connection Thanks