c#:only put "using blah.blah.blah" once instead of every page?

E

evolve

(in c#) does anyone know a way of having the "using" declaration just the
once

for example

in my website i keep having to put
using System.Data.SqlClient;

using System.Data;

using System.Configuration;





just so that i can get something out of the database

surely there is a way of having a bunch of global declarations?
 
W

William Ryan

Evolve:

If you are sticking System.Data.SqlClient over and over in your website,
that's more a function of your design than an inconvenience forced at the
behest of Visual Studio. Here's why I say that....

Let's say that you break up your project into presentation layer, a business
layer (which may iself be composed of muliple components) and a data access
layer. Ultimately at the back end you have a database that hosts its own
potential for logic.

The only way that you need to keep using libraries of Data in the
presentation layer is if you data functionality is tightly coupled with it.
You could easily declare a Datatable for instance, and let your DataLayer
pass data to and from it. Never on a form would you need a reference to SQL
Client or configuration.

You coudl also grab all of your configuration information non-related to
dataaccess and load them into Session Variables when the app starts. You
won't need to reference System.Configuration again (except if one of your
compnents needs it, but even this would only need to happen once per
component).

Now, for things like System.Collections and many such libraries, there
probably isn't a way to compleletey isolate it in one area b/c you need
collections all over the place. However, this is a relatively small problem
if you seperate everything into well grouped components.

HTH,

Bill
 

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

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top