When we connect to a database in ASP.NET you must specify the appropriate connection string. However most other instances where data is to be specified is done within an object.
For example why couldn't we have connection objects such as:
var connection = new connectionObject(){
DataSource = "myServerAddress",
IntialCatalog = "myDataBase",
UserId = "myUsername",
Password = "myPassword"
}
which is far better than some key/value string:
Data Source=myServerAddress;Initial Catalog=myDataBase;UserId=myUsername;Password=myPassword;
The only reason I can think of is to allow storage in web.config, but there would be nothing stopping us storing the individual values in there anyway.
I'm sure there are good reasons, but what are they?
Legacy, tradition but above all : flexibility.
Try to write (or just imagine) the connectionConfig object that could handle all the MS-SQL, Oracle and (nested) ODBC configurations. And that's only a few of the databases supporting .NET.
Also, the main purpose of such an object would be to be serialized in a (somewhat) human-readable form.
So XML is an alternative, a fixed (set of) objects is not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With