Advice needed: Using static class for Database access

  • Thread starter Thread starter tomi
  • Start date Start date
T

tomi

Hi

I'm creating a small IS and I'm wondering if is a good idea to create
one static class which will hold methods that will access the database.
So I'd have only one class in the memory used for all db access. I
think it is a good solution but .. maybe not.
What do you think . ??

I have a class

public static class DB Access {
public static void InsertUse(string username) {
.....
}
.....

tx in advance

Tomi
 
Sure. Many people to this, often because the data layer does not need to
maintain state.
 
Hi

I'm creating a small IS and I'm wondering if is a good idea to create
one static class which will hold methods that will access the database.
So I'd have only one class in the memory used for all db access. I
think it is a good solution but .. maybe not.
What do you think . ??

I have a class

public static class DB Access {
public static void InsertUse(string username) {
.....
}
....

It should work fine in most cases.

The only case I can think of that requires a state in the data layer
is if you require transactions outside of the database.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top