I do not want to split connection strings using string manipulation functions to get Server, Database, Username, and Password.
I read the following link and read the accepted answer, I found that is the best way to get username and password out from connection string, but what about Database Name?
Right way to get username and password from connection string?
How to get Database Name from Connection String using SqlConnectionStringBuilder. (does the DataSource is the Server name?)
Advertisement
Answer
See MSDN documentation for InitialCatalog Property:
Gets or sets the name of the database associated with the connection…
This property corresponds to the “Initial Catalog” and “database” keys within the connection string…