why do we add an application.config file for the connection string?? what is the purpose of this file
i want to know that why do we add an app.config file in c# projects for the connection string if our work is also access able by sim开发者_运维问答ple combining the command text and data adapter .. what is the functionality of this .xml file?
It allows you to change the runtime parameters (things like connection strings, for example if the database gets moved onto a different server) at runtime without having to recompile and re-distribute the application.
connection string is always required. sometimes it is passed implicitly so you don't notice it. app.config is just a place where they can be stored so you can change them when server name or other parameters change
Having the configuration data (including the Connection string) stored in a separate file form your binary, allows you the freedom to update the values stored in the configuration without having to recompile your application.
This can be great if for instance your application wants to talk to different databases for dev - Test and Production.
You do not have to use the app.config xml structure, its just a convenience that the .net framework provide code to read/update.
You could also store configuration data in your own format, pull it from Active Directory, or a dedicated configuration service.
精彩评论