In Appconfig code as follows
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku="NETFramework,Version=v4.5"/>
</startup>
<section name="dataConfiguration"; type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
</configSections>
<connectionStrings>
<add name="OneTransportConnectionString" providerName="System.Data.SqlClient" connectionString="server=One\Others;database=OneC768;user id=On998;password=988;Max pool size = 25;Min pool size = 0"/> </connectionStrings> </configuration>Program.cs page code as follows string connectionString = ConfigurationManager.ConnectionStrings["OneTransportConnectionString"].ConnectionString; SqlConnection sqlConnection = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(); SqlDataReader reader; cmd.CommandText = "Select * from Customers"; cmd.CommandType = CommandType.Text; cmd.Connection = sqlConnection; sqlConnection.Open(); reader = cmd.ExecuteReader(); Console.WriteLine("test"); sqlConnection.Close();When i run the above code shows error as followsConfiguration system failed to initializeThe above error code in below line as followsstring connectionString = ConfigurationManager.ConnectionStrings["OneTransportConnectionString"].ConnectionString;
</connectionStrings>
</configuration>
Program.cs page code as follows
string connectionString = ConfigurationManager.ConnectionStrings["OneTransportConnectionString"].ConnectionString;
SqlConnection sqlConnection = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand();
SqlDataReader reader;
cmd.CommandText = "Select * from Customers";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection;
sqlConnection.Open();
reader = cmd.ExecuteReader();
Console.WriteLine("test");
sqlConnection.Close();
please help me what is the mistake in my above code