Skip to content

System.Configuration.ConfigurationManager

renan paiva

Asked Apr 26, 2008, 7:23 AM EDT3 answers
Share
LinkedInX

Hi everyone,

I had installed in my computer Visual Studio 2008 Trial when I try use the class ConfigurationManager to change in run time my stringconnection seems that class don't exists.

What I must do?

Best Regards,

Renan Paiva

msn: [email protected]

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Did you add a reference to System.Configuration to your project? Even though you can access the System.Configuration namespace without it, you still cannot access the ConfigurationManager class without adding it :)
    0
  • 0

    First thanks for your reply follow there is my font

    C#
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Configuration;
    namespace Pipe_Analyst_Control
    {
    public partial class Conexao : Form
    {
    public Conexao()
    {
    InitializeComponent();
    }
    private void Cancelbutton_Click(object sender, EventArgs e)
    {
    this.Dispose();
    }
    private void Savebutton_Click(object sender, EventArgs e)
    {
    SqlConnectionStringBuilder bilder = new SqlConnectionStringBuilder();
    bilder.DataSource = ServidortextBox.Text.Trim();
    bilder.InitialCatalog = "pipedata";
    bilder.IntegratedSecurity = true;
    bilder.UserID = UsertextBox.Text.Trim();
    bilder.Password = SenhatextBox.Text.Trim();
    ConfigurationSettings.AppSettings.Set("pipedataConnectionString", bilder.ConnectionString);
    //here I must use ConfigurationManager but it is unviable.
    }
    private void Testbutton_Click(object sender, EventArgs e)
    {
    SqlConnection SqlCon = new SqlConnection(Pipe_Analyst_Control.Properties.Settings.Default.pipedataConnectionString);
    try
    {
    SqlCon.Open();
    MessageBox.Show("ConexÆo configurada com sucesso", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
    }
    catch
    {
    MessageBox.Show("A conexÆo falhou por favor configure novamente ou tente salvar as configura‡äes vigentes", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    }
    }
    }
    0
  • 0

    So sorry I'm brazilam and my English is so poor, I add reference and then appear the class ConfigurationManager to me thank you so much.

    0