I have a simple WinForm that I'm using to try to help me with ADO.NET. It has a datagridview
I have added a compact sql server database to the project called experiment.sdf
In the App.config file I have added the following. I used a previous project app file to base this on so maybe there's an error in here?:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="DatabaseDGVexperiments.Properties.Settings.DatabaseDGVexperimentsConnStg"
connectionString="Data Source=|DataDirectory|\experiment.sdf"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
</configuration>
I've added a reference to the configuration library.
Behind the form is the following code:
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DatabaseDGVexperimentsConnStg"].ConnectionString);
When it hits the line SqlConnection conn = ...
I get an error NullReferenceException was unhandled
. How do I fix this?