Solved

Configuration system failed to initialize

Posted on 2011-09-17
1
572 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
1 Comment
 
LVL 14

Accepted Solution

by:
nishant joshi earned 500 total points
Comment Utility
try to use Properties.setting.Default.-----------
your connection string
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now