Good afternoon All,

I have a query which has been plaguing me for quite a while.

I am trying to open a database that I have created on my local machine in Visual C# 2008 here. I can connect and manipulate it in C# but when I try to access it with my developed application I run into errors.

Currently on my main form, my code to access the support.sdf log looks like this:

public Client_main()
{
InitializeComponent();

SqlConnection sqlconn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["DBCONNECTION"]);

try
{

sqlconn.Open();
}
catch (Exception e)
{

MessageBox.Show("Error: " + e);
}
}

I am using System.Data.Sqlclient and System.Configuration in which has been added to the project as well.

Now the contents of my App.config file that is part of the project looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="DBCONNECTION" connectionString="Data Source=|DataDirectory|\support.sdf;Persist Security Info=False"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
</configuration>


I thought with these two together, I have the right call to open up the database and begin to manipulate it with my program. Unfortunately I am given the exception error:

Error: System.InvalidOperationException: The ConnectionString property has not been initialized.
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection out Connection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open().

These errors are reported in the constructor of which I have posted above. This is really confusing me, I have looked at multiple tutorials and believe that I have the right connection string that should Initialise a proper connection.

Any advice or hints would be greatly appreciated.

Regards,

Michael