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?
ToString()
would build the appropriate connection string using its properties. – BoltClock