Exception - The ConnectionString property has not been initialized
 
Author:
Filed Under: Issues and Exceptions
Published Date: May 21, 2009
Views: 6971
 

Abstract: Here Mudassar Ahmed Khan has explained the Exception The ConnectionString property has not been initialized while connecting to SQL Server in ASP.Net

Comments:  0

 

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.

 

Cause

The ConnectionString property of SqlConnection object is not set or it is invalid.

 

Solution

1. Check you are assigning value to SqlConnection Object or not. For more information you can visit my article Parameterized Queries ADO.Net. I have explained how to get connection string from web.config

2. If connection string is coming from web.config check the key name is correct.

3. If the variable is used it is not reset somewhere









Related Articles



Comments

No comments have been added to this article.

Add comments

You can add your comment about this article using the form below. Make sure you provide a valid email address
else you won't be notified when the author replies to your comment

Please note that all comments are moderated and will be deleted if they are
  • Not relavant to the article
  • Spam
  • Advertising campaigns or links to other sites
  • Abusive content.
Please do not post code, scripts or snippets.

Name*: Required
Email*: Required
Comment*: Required
Security code*: CaptchaInvalid Security Code
  Submit