Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
C# DB Connection Code Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01311457
Message ID:
01311639
Vues:
21
>
>By this is pretty good for a first attempt. What do you think?

Mind some constructive criticism? (I don't mean any of this to come across snarky)
These are just mostly "standards" people use, so it really won't effect how your code works in any way.

I'd suggest you use an enumeration instead of an integer, it makes the code a bit easier to read.

ex.
public enum ConnectionType
{
    Sql,
    OleDB,
    ODBC
}
Then your switch looks like:
switch (iConnectionType)
{
   // Sql Data Provider
    case ConnectionType.Sql:
...
}
Members of a class are also normally either private or protected. If you need to expose them, create a property (a member with a get/set).

ex..
private string sConnString = "";
public string ConnString
{
   get { return this.sConnString; }
   set { this.sConnString = value; }
}
Also, I think you'll find most .NET devs don't use type prefixes like we do in VFP. Local vars/parameters are camel case (lowerCase). Members are either name m_memberName or _memberName. Properties are usually ProperCase.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform