Solved

Configuration system failed to initialize

Posted on 2011-09-17
1
587 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
ID: 36555530
try to use Properties.setting.Default.-----------
your connection string
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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