Solved

Configuration system failed to initialize

Posted on 2011-09-17
1
582 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 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