In this article I will explain with an example, how to resolve the error: The ConnectionString property has not been initialized. in ASP.Net.
Error
The following error occurs when ConnectionString property of SqlConnection object is not set or it is invalid.
Server Error in '/.Net' Application.
The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.
Solution
The solution to this problem is to make sure following things are correct:
1. Check if you are assigning value to SqlConnection object or not.
2. If connection string is coming from web.config check the key name is correct.
3. The variable name should be unique.