Learning While Aging

Error message: Object reference not set to an instance of an object

If you use the TableAdapter Configuration Wizard in Visual Studio 2005 to create a strong-typed dataset (as described in Scott Mitchell’s ASP.NET 2.0 Data Access Tutorial – Creating a Data Access Layer), you will be asked if you would like to save the database connection string in the configuration file. If you choose to save it, it will be placed in the <connectionStrings> section.

Save the Connection String to <code>Web.config</code>

But what if you want to change the name of the saved connection string later? It is kinda tricky. If you manually change the name in the configuration file, you will find that every time you save a file, you will get an error message: object reference not set to an instance of an object. It is because when you manually change the name of the connection string in the configuration file, Visual Studio 2005 designer does not know the change, so it still uses the old name to retrieve the connection string and causes the error. So to avoid this error, you should change the name of the connection string in the designer, not in the configuration file.

[ratings]