?
Solved

Configuration system failed to initialize

Posted on 2011-09-17
1
Medium Priority
?
598 Views
Last Modified: 2012-05-12
Hi I am trying to establish connection with server and encouter "Configuration system failed to initiaze at "ConnectionString = ConfigurationManager.AppSettings.Get("ConnectionString");"

"
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;

namespace Connections
{
    
    public partial class Form1 : System.Windows.Forms.Form 
    {
        private string ConnectionString;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
         
            ConnectionString = ConfigurationManager.AppSettings.Get("ConnectionString");
            SqlConnection con = new SqlConnection(this.ConnectionString);
            con.Open();
            MessageBox.Show(con.State.ToString());
            con.Close();
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.Refresh();
           //ConnectionString = ConfigurationSettings.AppSettings.Get("ConnectionString");

        }
    }
}


///////////////////////////////////////////////////////////

<?xml version="1.0"?>
<configuration>
  
<configSections>  
</configSections>
  
<connectionStrings>
  <add name ="MaterialProdApp.Properties.Settings.CAMSConnectionString" connectionString="Data Source=TRamanah\SQLEXPRESS;Initial Catalog=CAMS;Persist Security Info=True;User ID=sa" providerName="System.Data.SqlClient" />
</connectionStrings>
  
<appSetting>
  <!-- Configure Sql Cennection String here-->
  <!--  Configure SQL Connection string here  -->
  <add key="LogErrorFile" value="ErrorLog.txt" />
  <add key="ProductionLine" value="A" />
  <add key="ConnectionString1" value="Data Source=172.16.93.252;Initial Catalog=CAMS;User ID=sa;Password=camssa;" />
  <add key="ConnectionString" value="Data Source=(local)\SQLEXPRESS;Initial Catalog=CAMS;User ID=sa;Password=abc123;" />
  <add key="ClientSettingsProvider.ServiceUri" value="" />
</appSetting>
  
</configuration>

Open in new window

0
Comment
Question by:TITO2009
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
nishant joshi earned 2000 total points
ID: 36555530
try to use Properties.setting.Default.-----------
your connection string
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question