Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subclassing Connections
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01022145
Message ID:
01022293
Vues:
13
Bernard,

Yes you don't want to hardcode the connection string, hence Bonnie's suggestion to store it in the Config file. Where you store it is up to you but the Config file is the easiest place. With a little help you can even get configuration settings more optimized with strong typing, encryption adn read/write access.

http://www.west-wind.com/presentations/configurationclass/configurationclass.asp

As to subclassing - it doesn't make a lot of sense to have a 'connection' class. In most situations what you want is have a business object that has the connection string (or if you think you really need a whole Connection class) attached to the business object. So that the business object can get at the string whenever needed.

The way I do this is that I have a 'global' configuration class that's attached to an App class (App.Configuration). The business object has access to this global object and can read configuration information including the database backend type and connection string as needed when making connections. A typical constructor of a bus object then loooks something like this:
public busInvoice()
{
	this.ConnectionString = App.Configuration.ConnectionString;
	this.ConnectType = App.Configuration.ConnectType;

	this.NewRowBlankValues = true;
	this.DataRowUpdateMode = DataRowUpdateModes.OptimizedByPk;

	this.Tablename = "wws_invoice";
}
The use of a configuration class is pretty handy because it gives you access to configurable and customizable settings everywhere.

+++ Rick ---


>Hi
>
>Again, thanks for the reply..
>
>I think you are correct when you say I don't want to hard code the connection string into the application. I think I'm over engineering this one !
>
>If I was to store my user logon information, user id and passwords etc, in a config file wouldn't this allow anybody to view this information ? Wouldn't this lead to a security problem ?
>
>Do you know the standard approach to address this issue? If it is an issue...
>
>Thanks for the help. Bernard...
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform