You could create a static class for the connection with
static properties for the connection object itself and
all of the associated properties. Just be aware that
only one object can use a connection at one time.
As far as the namespace, it depends on whether you will
want to reuse this class for other apps. The normal
naming convention is
CompanyName.Maj orSystem.MajorC lassification.E tc.
Although, I find it hard to create a new namespace for a
single class - unless the solution is big enough that it
would make less sense to stick it in some generic
namespace.
[color=blue]
>-----Original Message-----
>hi,
>
>i have a couple of classes which look something like[/color]
this:[color=blue]
>
>namespace BookStore
>{
> public class Customer
> {
> public Customer()
> {
> // initialise customer object here
> }
> }
>}
>
>
>namespace BookStore
>{
> public class Order
> {
> public Order()
> {
> // initialise order object here
> }
> }
>}
>
>
>i want to create a function takes in some parameters[/color]
(ie: connection object,[color=blue]
>connection string, etc), and this function should make a[/color]
connection to the[color=blue]
>database. i want this function to be accessible by both[/color]
classes. where would[color=blue]
>i put this code and what would my class look like (in[/color]
terms of namespace,[color=blue]
>class name, etc). also, how would i call the function?
>
>thanks.
>
>
>.
>[/color]
static properties for the connection object itself and
all of the associated properties. Just be aware that
only one object can use a connection at one time.
As far as the namespace, it depends on whether you will
want to reuse this class for other apps. The normal
naming convention is
CompanyName.Maj orSystem.MajorC lassification.E tc.
Although, I find it hard to create a new namespace for a
single class - unless the solution is big enough that it
would make less sense to stick it in some generic
namespace.
[color=blue]
>-----Original Message-----
>hi,
>
>i have a couple of classes which look something like[/color]
this:[color=blue]
>
>namespace BookStore
>{
> public class Customer
> {
> public Customer()
> {
> // initialise customer object here
> }
> }
>}
>
>
>namespace BookStore
>{
> public class Order
> {
> public Order()
> {
> // initialise order object here
> }
> }
>}
>
>
>i want to create a function takes in some parameters[/color]
(ie: connection object,[color=blue]
>connection string, etc), and this function should make a[/color]
connection to the[color=blue]
>database. i want this function to be accessible by both[/color]
classes. where would[color=blue]
>i put this code and what would my class look like (in[/color]
terms of namespace,[color=blue]
>class name, etc). also, how would i call the function?
>
>thanks.
>
>
>.
>[/color]
Comment