What is a configuration file?

Source: Internet
Author: User

If the database connection string is hard-coded inCode, After compilation
If you want to change it, it is not easy to change it, so it is best to put it in the configuration file.
Winform is app. config
Webform is Web. config

<? XML version = "1.0" encoding = "UTF-8"?>
<Configuration>
<Configsections>
</Configsections>
<Connectionstrings>
<Add name = "windowsapplication11.properties. settings. mica_salemgnconnectionstring"
Connectionstring = "Data Source = mica-server; initial catalog = mica_salemgn; user id = sa"
Providername = "system. Data. sqlclient"/>
</Connectionstrings>
</Configuration>

You can use configurationmanager. connectionstring ["windowsapplication11.properties. settings. mica_salemgnconnectionstring"]. connectionstring;

Sqlconnection conn = new sqlconnection (the above string is in the middle );

Sqlconnection conn = new sqlconnection (system. configuration. configurationmanager. connectionstrings
["Windowsformsapplication3.properties. settings. testconnectionstring"]. connectionstring );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.