Home
Do you hard code your ConnectionString?
  v3.0 Posted at 10/20/2010 7:56 PM by System Account
We don't like hard coded string inside our programme. We are using model-driven development, in which we create or reuse code, and perform changes in configuration file rather the in-code changing. More information on implementing our configuration.
connection.ConnectionString = "
Provider=SQLOLEDB;
Data Source=server_name_or_address; Initial Catalog=database_name;
User ID=username; Password=password; ";

   connection.Open();
Bad code - use the lengthy connection string.
connection.ConnectionString = ConfigurationManager.Items["ConnectionString"];

 connection.Open();
Figure: Good Code - Use ConfigurationManager to handle the connection string.
We have a program called SSW Code Auditor to check for this rule.

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments:

    Note: Social Media login for Yotpo is not working in IE or Safari, please use Chrome. We are waiting for Yotpo to fix it.