Get connection string from App.config












339














var connection = ConnectionFactory.GetConnection(
ConfigurationManager.ConnectionStrings["Test"]
.ConnectionString, DataBaseProvider);


And this is my App.config:



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="Test" connectionString="Data Source=.;Initial Catalog=OmidPayamak;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


But when my project runs this is my error:




Object reference not set to an instance of an object.











share|improve this question




















  • 5




    Where did you put that App.config? Project of application you're running or maybe some dll? You need first
    – abatishchev
    Jun 30 '11 at 15:02






  • 3




    Add a reference to System.Configuration.dll, and you should be able to use the System.Configuration.ConfigurationManager.
    – daszarrin
    Jul 22 '13 at 10:27










  • Your connection string has a typo. You need a space between "Integrated" and "Security"
    – Onur Omer
    Aug 23 '16 at 18:34










  • @OnurOmer - question has been updated to include the space ("Integrated Security" instead of "IntegratedSecurity")
    – SlimsGhost
    Mar 14 '17 at 15:39
















339














var connection = ConnectionFactory.GetConnection(
ConfigurationManager.ConnectionStrings["Test"]
.ConnectionString, DataBaseProvider);


And this is my App.config:



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="Test" connectionString="Data Source=.;Initial Catalog=OmidPayamak;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


But when my project runs this is my error:




Object reference not set to an instance of an object.











share|improve this question




















  • 5




    Where did you put that App.config? Project of application you're running or maybe some dll? You need first
    – abatishchev
    Jun 30 '11 at 15:02






  • 3




    Add a reference to System.Configuration.dll, and you should be able to use the System.Configuration.ConfigurationManager.
    – daszarrin
    Jul 22 '13 at 10:27










  • Your connection string has a typo. You need a space between "Integrated" and "Security"
    – Onur Omer
    Aug 23 '16 at 18:34










  • @OnurOmer - question has been updated to include the space ("Integrated Security" instead of "IntegratedSecurity")
    – SlimsGhost
    Mar 14 '17 at 15:39














339












339








339


45





var connection = ConnectionFactory.GetConnection(
ConfigurationManager.ConnectionStrings["Test"]
.ConnectionString, DataBaseProvider);


And this is my App.config:



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="Test" connectionString="Data Source=.;Initial Catalog=OmidPayamak;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


But when my project runs this is my error:




Object reference not set to an instance of an object.











share|improve this question















var connection = ConnectionFactory.GetConnection(
ConfigurationManager.ConnectionStrings["Test"]
.ConnectionString, DataBaseProvider);


And this is my App.config:



<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="Test" connectionString="Data Source=.;Initial Catalog=OmidPayamak;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


But when my project runs this is my error:




Object reference not set to an instance of an object.








c# ado.net exception-handling connection-string app-config






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 14 '17 at 15:37









SlimsGhost

2,6141515




2,6141515










asked Jun 30 '11 at 14:54









Moham ad Jafari

1,6962103




1,6962103








  • 5




    Where did you put that App.config? Project of application you're running or maybe some dll? You need first
    – abatishchev
    Jun 30 '11 at 15:02






  • 3




    Add a reference to System.Configuration.dll, and you should be able to use the System.Configuration.ConfigurationManager.
    – daszarrin
    Jul 22 '13 at 10:27










  • Your connection string has a typo. You need a space between "Integrated" and "Security"
    – Onur Omer
    Aug 23 '16 at 18:34










  • @OnurOmer - question has been updated to include the space ("Integrated Security" instead of "IntegratedSecurity")
    – SlimsGhost
    Mar 14 '17 at 15:39














  • 5




    Where did you put that App.config? Project of application you're running or maybe some dll? You need first
    – abatishchev
    Jun 30 '11 at 15:02






  • 3




    Add a reference to System.Configuration.dll, and you should be able to use the System.Configuration.ConfigurationManager.
    – daszarrin
    Jul 22 '13 at 10:27










  • Your connection string has a typo. You need a space between "Integrated" and "Security"
    – Onur Omer
    Aug 23 '16 at 18:34










  • @OnurOmer - question has been updated to include the space ("Integrated Security" instead of "IntegratedSecurity")
    – SlimsGhost
    Mar 14 '17 at 15:39








5




5




Where did you put that App.config? Project of application you're running or maybe some dll? You need first
– abatishchev
Jun 30 '11 at 15:02




Where did you put that App.config? Project of application you're running or maybe some dll? You need first
– abatishchev
Jun 30 '11 at 15:02




3




3




Add a reference to System.Configuration.dll, and you should be able to use the System.Configuration.ConfigurationManager.
– daszarrin
Jul 22 '13 at 10:27




Add a reference to System.Configuration.dll, and you should be able to use the System.Configuration.ConfigurationManager.
– daszarrin
Jul 22 '13 at 10:27












Your connection string has a typo. You need a space between "Integrated" and "Security"
– Onur Omer
Aug 23 '16 at 18:34




Your connection string has a typo. You need a space between "Integrated" and "Security"
– Onur Omer
Aug 23 '16 at 18:34












@OnurOmer - question has been updated to include the space ("Integrated Security" instead of "IntegratedSecurity")
– SlimsGhost
Mar 14 '17 at 15:39




@OnurOmer - question has been updated to include the space ("Integrated Security" instead of "IntegratedSecurity")
– SlimsGhost
Mar 14 '17 at 15:39












18 Answers
18






active

oldest

votes


















423














Can't you just do the following:



var connection = 
System.Configuration.ConfigurationManager.
ConnectionStrings["Test"].ConnectionString;


Your assembly also needs a reference to System.Configuration.dll






share|improve this answer























  • I was not setting the reference due to which getting error.
    – Muhammad Danish
    Oct 4 '13 at 8:35






  • 7




    I know that this is a C# question, but since this is the top of the google search results, to do this in VB, it's System.Configuration.ConfigurationManager.ConnectionStrings("Test").ConnectionString for those of us who have to maintain VB code
    – JFA
    Feb 14 '17 at 16:43





















272














Since this is very common question I have prepared some screen shots from Visual Studio to make it easy to follow in 4 simple steps.



get connection string from app.config






share|improve this answer



















  • 20




    Love this answer. By default in my version of VS (VS2012 Ultimate) this library is not included, but using System.Configuration still works
    – David Colwell
    Jul 12 '13 at 4:04






  • 1




    Could do with stage 4 in the answer. I had typing up stuff..
    – PriceCheaperton
    Jan 1 '14 at 18:29






  • 2




    I really HAD TO add the reference or the using was not underlined but still ConfigurationManager unknown. Thanks!
    – CodingYourLife
    Dec 13 '17 at 15:09



















32














string str = Properties.Settings.Default.myConnectionString; 





share|improve this answer



















  • 1




    hmm.. something new to learn.. thanks
    – saun4frsh
    Jul 26 '14 at 16:58






  • 1




    What if app.config is added as a link to a project ?
    – FrenkyB
    Apr 8 '15 at 19:50






  • 1




    This will only work if your connection string is an app setting, it will not work if to retrieve <connectionStrings> elements from app.config (which is what the OP is asking for!).
    – BrainSlugs83
    May 2 at 19:52



















27














Also check that you've included the System.Configuration dll under your references. Without it, you won't have access to the ConfigurationManager class in the System.Configuration namespace.






share|improve this answer





























    19














    First Add a reference of System.Configuration to your page.



    using System.Configuration;


    Then According to your app.config get the connection string as follow.



    string conStr = ConfigurationManager.ConnectionStrings["Test"].ToString();


    That's it now you have your connection string in your hand and you can use it.






    share|improve this answer































      11














      //Get Connection from web.config file
      public static OdbcConnection getConnection()
      {
      OdbcConnection con = new OdbcConnection();
      con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString;
      return con;
      }





      share|improve this answer































        6














        Try this out



        string abc = ConfigurationManager.ConnectionStrings["CharityManagement"].ConnectionString;





        share|improve this answer































          3














          1) Create a new form and add this:



          Imports System.Configuration
          Imports Operaciones.My.MySettings

          Public NotInheritable Class frmconexion

          Private Shared _cnx As String
          Public Shared Property ConexionMySQL() As String
          Get
          Return My.MySettings.Default.conexionbd
          End Get
          Private Set(ByVal value As String)
          _cnx = value
          End Set
          End Property

          End Class


          then when you want to use the connection do this in ur form:



           Private Sub frmInsert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

          Dim cn As New MySqlConnection(frmconexion.ConexionMySQL)
          cn.open()


          and thats it. You will be connected to the DB and can do stuff.



          This is for vb.net but the logic is the same.






          share|improve this answer































            3














            Have you tried:



            var connection = new ConnectionFactory().GetConnection(
            ConfigurationManager.ConnectionStrings["Test"]
            .ConnectionString, DataBaseProvider);





            share|improve this answer































              3














              I had the same Issue. my solution was built up from two projects. A Class library and a website referencing to the class library project. the problem was that i was trying to access the App.config in my Class library project but the system was searching in Web.config of the website. I put the connection string inside Web.config and ... problem solved!



              The main reason was that despite ConfigurationManager was used in another assembly it was searching inside the runnig project .






              share|improve this answer





























                2














                string sTemp = System.Configuration.ConfigurationManager.ConnectionStrings["myDB In app.config"].ConnectionString;





                share|improve this answer































                  1














                  You can fetch the connection string by using below line of code -



                  using System; using System.Configuration;

                  var connectionString=ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;


                  Here is a reference :
                  Connection String from App.config






                  share|improve this answer

















                  • 1




                    I did the same as u said but same null reference error I am getting.
                    – Enigmatic Mind
                    Sep 13 '16 at 18:41



















                  1














                  It seems like problem is not with reference, you are getting connectionstring as null so please make sure you have added the value to the config file your running project meaning the main program/library that gets started/executed first.






                  share|improve this answer





























                    1














                    It is possible that the OP in this question is trying to use an App.Config within a dll.



                    In this case, the code is actually trying to access the App.Config of the executable and not the dll. Since the name is not found, you get a Null returned, hence the exception shown.



                    The following post may be helpful:
                    ConnectionString from app.config of a DLL is null






                    share|improve this answer























                    • my case exactly, thanks
                      – user1451111
                      Nov 2 '17 at 9:30



















                    1














                    First you have to add System.Configuration reference to your project and then use below code to get connection string.



                    _connectionString = ConfigurationManager.ConnectionStrings["MYSQLConnection"].ConnectionString.ToString();





                    share|improve this answer































                      1














                      This worked for me:



                      string connection = System.Configuration.ConfigurationManager.ConnectionStrings["Test"].ConnectionString;


                      Outputs:




                      Data Source=.;Initial Catalog=OmidPayamak;IntegratedSecurity=True"







                      share|improve this answer































                        0














                        I referenced System.Configuration library and I have the same error.
                        The debug files had not their app.config, create manually this file.
                        The error is, I solved this copying the file "appname.exe.config" in debug folder. The IDE was not create the file.






                        share|improve this answer































                          0














                          I solved the problem by using the index to read the string and checking one by one. Reading using the name still gives the same error.

                          I have the problem when I develop a C# window application, I did not have the problem in my asp.net application. There must be something in the setting which is not right.






                          share|improve this answer





















                            Your Answer






                            StackExchange.ifUsing("editor", function () {
                            StackExchange.using("externalEditor", function () {
                            StackExchange.using("snippets", function () {
                            StackExchange.snippets.init();
                            });
                            });
                            }, "code-snippets");

                            StackExchange.ready(function() {
                            var channelOptions = {
                            tags: "".split(" "),
                            id: "1"
                            };
                            initTagRenderer("".split(" "), "".split(" "), channelOptions);

                            StackExchange.using("externalEditor", function() {
                            // Have to fire editor after snippets, if snippets enabled
                            if (StackExchange.settings.snippets.snippetsEnabled) {
                            StackExchange.using("snippets", function() {
                            createEditor();
                            });
                            }
                            else {
                            createEditor();
                            }
                            });

                            function createEditor() {
                            StackExchange.prepareEditor({
                            heartbeatType: 'answer',
                            autoActivateHeartbeat: false,
                            convertImagesToLinks: true,
                            noModals: true,
                            showLowRepImageUploadWarning: true,
                            reputationToPostImages: 10,
                            bindNavPrevention: true,
                            postfix: "",
                            imageUploader: {
                            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                            allowUrls: true
                            },
                            onDemand: true,
                            discardSelector: ".discard-answer"
                            ,immediatelyShowMarkdownHelp:true
                            });


                            }
                            });














                            draft saved

                            draft discarded


















                            StackExchange.ready(
                            function () {
                            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6536715%2fget-connection-string-from-app-config%23new-answer', 'question_page');
                            }
                            );

                            Post as a guest















                            Required, but never shown

























                            18 Answers
                            18






                            active

                            oldest

                            votes








                            18 Answers
                            18






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes









                            423














                            Can't you just do the following:



                            var connection = 
                            System.Configuration.ConfigurationManager.
                            ConnectionStrings["Test"].ConnectionString;


                            Your assembly also needs a reference to System.Configuration.dll






                            share|improve this answer























                            • I was not setting the reference due to which getting error.
                              – Muhammad Danish
                              Oct 4 '13 at 8:35






                            • 7




                              I know that this is a C# question, but since this is the top of the google search results, to do this in VB, it's System.Configuration.ConfigurationManager.ConnectionStrings("Test").ConnectionString for those of us who have to maintain VB code
                              – JFA
                              Feb 14 '17 at 16:43


















                            423














                            Can't you just do the following:



                            var connection = 
                            System.Configuration.ConfigurationManager.
                            ConnectionStrings["Test"].ConnectionString;


                            Your assembly also needs a reference to System.Configuration.dll






                            share|improve this answer























                            • I was not setting the reference due to which getting error.
                              – Muhammad Danish
                              Oct 4 '13 at 8:35






                            • 7




                              I know that this is a C# question, but since this is the top of the google search results, to do this in VB, it's System.Configuration.ConfigurationManager.ConnectionStrings("Test").ConnectionString for those of us who have to maintain VB code
                              – JFA
                              Feb 14 '17 at 16:43
















                            423












                            423








                            423






                            Can't you just do the following:



                            var connection = 
                            System.Configuration.ConfigurationManager.
                            ConnectionStrings["Test"].ConnectionString;


                            Your assembly also needs a reference to System.Configuration.dll






                            share|improve this answer














                            Can't you just do the following:



                            var connection = 
                            System.Configuration.ConfigurationManager.
                            ConnectionStrings["Test"].ConnectionString;


                            Your assembly also needs a reference to System.Configuration.dll







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Mar 8 '17 at 10:22









                            niico

                            3,693104994




                            3,693104994










                            answered Jun 30 '11 at 20:58









                            Duffp

                            4,5202914




                            4,5202914












                            • I was not setting the reference due to which getting error.
                              – Muhammad Danish
                              Oct 4 '13 at 8:35






                            • 7




                              I know that this is a C# question, but since this is the top of the google search results, to do this in VB, it's System.Configuration.ConfigurationManager.ConnectionStrings("Test").ConnectionString for those of us who have to maintain VB code
                              – JFA
                              Feb 14 '17 at 16:43




















                            • I was not setting the reference due to which getting error.
                              – Muhammad Danish
                              Oct 4 '13 at 8:35






                            • 7




                              I know that this is a C# question, but since this is the top of the google search results, to do this in VB, it's System.Configuration.ConfigurationManager.ConnectionStrings("Test").ConnectionString for those of us who have to maintain VB code
                              – JFA
                              Feb 14 '17 at 16:43


















                            I was not setting the reference due to which getting error.
                            – Muhammad Danish
                            Oct 4 '13 at 8:35




                            I was not setting the reference due to which getting error.
                            – Muhammad Danish
                            Oct 4 '13 at 8:35




                            7




                            7




                            I know that this is a C# question, but since this is the top of the google search results, to do this in VB, it's System.Configuration.ConfigurationManager.ConnectionStrings("Test").ConnectionString for those of us who have to maintain VB code
                            – JFA
                            Feb 14 '17 at 16:43






                            I know that this is a C# question, but since this is the top of the google search results, to do this in VB, it's System.Configuration.ConfigurationManager.ConnectionStrings("Test").ConnectionString for those of us who have to maintain VB code
                            – JFA
                            Feb 14 '17 at 16:43















                            272














                            Since this is very common question I have prepared some screen shots from Visual Studio to make it easy to follow in 4 simple steps.



                            get connection string from app.config






                            share|improve this answer



















                            • 20




                              Love this answer. By default in my version of VS (VS2012 Ultimate) this library is not included, but using System.Configuration still works
                              – David Colwell
                              Jul 12 '13 at 4:04






                            • 1




                              Could do with stage 4 in the answer. I had typing up stuff..
                              – PriceCheaperton
                              Jan 1 '14 at 18:29






                            • 2




                              I really HAD TO add the reference or the using was not underlined but still ConfigurationManager unknown. Thanks!
                              – CodingYourLife
                              Dec 13 '17 at 15:09
















                            272














                            Since this is very common question I have prepared some screen shots from Visual Studio to make it easy to follow in 4 simple steps.



                            get connection string from app.config






                            share|improve this answer



















                            • 20




                              Love this answer. By default in my version of VS (VS2012 Ultimate) this library is not included, but using System.Configuration still works
                              – David Colwell
                              Jul 12 '13 at 4:04






                            • 1




                              Could do with stage 4 in the answer. I had typing up stuff..
                              – PriceCheaperton
                              Jan 1 '14 at 18:29






                            • 2




                              I really HAD TO add the reference or the using was not underlined but still ConfigurationManager unknown. Thanks!
                              – CodingYourLife
                              Dec 13 '17 at 15:09














                            272












                            272








                            272






                            Since this is very common question I have prepared some screen shots from Visual Studio to make it easy to follow in 4 simple steps.



                            get connection string from app.config






                            share|improve this answer














                            Since this is very common question I have prepared some screen shots from Visual Studio to make it easy to follow in 4 simple steps.



                            get connection string from app.config







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Dec 19 '14 at 6:12









                            Mehrad

                            2,66932849




                            2,66932849










                            answered Mar 20 '13 at 17:44









                            Fredrick Gauss

                            4,34412040




                            4,34412040








                            • 20




                              Love this answer. By default in my version of VS (VS2012 Ultimate) this library is not included, but using System.Configuration still works
                              – David Colwell
                              Jul 12 '13 at 4:04






                            • 1




                              Could do with stage 4 in the answer. I had typing up stuff..
                              – PriceCheaperton
                              Jan 1 '14 at 18:29






                            • 2




                              I really HAD TO add the reference or the using was not underlined but still ConfigurationManager unknown. Thanks!
                              – CodingYourLife
                              Dec 13 '17 at 15:09














                            • 20




                              Love this answer. By default in my version of VS (VS2012 Ultimate) this library is not included, but using System.Configuration still works
                              – David Colwell
                              Jul 12 '13 at 4:04






                            • 1




                              Could do with stage 4 in the answer. I had typing up stuff..
                              – PriceCheaperton
                              Jan 1 '14 at 18:29






                            • 2




                              I really HAD TO add the reference or the using was not underlined but still ConfigurationManager unknown. Thanks!
                              – CodingYourLife
                              Dec 13 '17 at 15:09








                            20




                            20




                            Love this answer. By default in my version of VS (VS2012 Ultimate) this library is not included, but using System.Configuration still works
                            – David Colwell
                            Jul 12 '13 at 4:04




                            Love this answer. By default in my version of VS (VS2012 Ultimate) this library is not included, but using System.Configuration still works
                            – David Colwell
                            Jul 12 '13 at 4:04




                            1




                            1




                            Could do with stage 4 in the answer. I had typing up stuff..
                            – PriceCheaperton
                            Jan 1 '14 at 18:29




                            Could do with stage 4 in the answer. I had typing up stuff..
                            – PriceCheaperton
                            Jan 1 '14 at 18:29




                            2




                            2




                            I really HAD TO add the reference or the using was not underlined but still ConfigurationManager unknown. Thanks!
                            – CodingYourLife
                            Dec 13 '17 at 15:09




                            I really HAD TO add the reference or the using was not underlined but still ConfigurationManager unknown. Thanks!
                            – CodingYourLife
                            Dec 13 '17 at 15:09











                            32














                            string str = Properties.Settings.Default.myConnectionString; 





                            share|improve this answer



















                            • 1




                              hmm.. something new to learn.. thanks
                              – saun4frsh
                              Jul 26 '14 at 16:58






                            • 1




                              What if app.config is added as a link to a project ?
                              – FrenkyB
                              Apr 8 '15 at 19:50






                            • 1




                              This will only work if your connection string is an app setting, it will not work if to retrieve <connectionStrings> elements from app.config (which is what the OP is asking for!).
                              – BrainSlugs83
                              May 2 at 19:52
















                            32














                            string str = Properties.Settings.Default.myConnectionString; 





                            share|improve this answer



















                            • 1




                              hmm.. something new to learn.. thanks
                              – saun4frsh
                              Jul 26 '14 at 16:58






                            • 1




                              What if app.config is added as a link to a project ?
                              – FrenkyB
                              Apr 8 '15 at 19:50






                            • 1




                              This will only work if your connection string is an app setting, it will not work if to retrieve <connectionStrings> elements from app.config (which is what the OP is asking for!).
                              – BrainSlugs83
                              May 2 at 19:52














                            32












                            32








                            32






                            string str = Properties.Settings.Default.myConnectionString; 





                            share|improve this answer














                            string str = Properties.Settings.Default.myConnectionString; 






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 17 '15 at 20:29









                            Celeo

                            4,28382535




                            4,28382535










                            answered Oct 3 '13 at 11:38









                            gjijo

                            1,0931113




                            1,0931113








                            • 1




                              hmm.. something new to learn.. thanks
                              – saun4frsh
                              Jul 26 '14 at 16:58






                            • 1




                              What if app.config is added as a link to a project ?
                              – FrenkyB
                              Apr 8 '15 at 19:50






                            • 1




                              This will only work if your connection string is an app setting, it will not work if to retrieve <connectionStrings> elements from app.config (which is what the OP is asking for!).
                              – BrainSlugs83
                              May 2 at 19:52














                            • 1




                              hmm.. something new to learn.. thanks
                              – saun4frsh
                              Jul 26 '14 at 16:58






                            • 1




                              What if app.config is added as a link to a project ?
                              – FrenkyB
                              Apr 8 '15 at 19:50






                            • 1




                              This will only work if your connection string is an app setting, it will not work if to retrieve <connectionStrings> elements from app.config (which is what the OP is asking for!).
                              – BrainSlugs83
                              May 2 at 19:52








                            1




                            1




                            hmm.. something new to learn.. thanks
                            – saun4frsh
                            Jul 26 '14 at 16:58




                            hmm.. something new to learn.. thanks
                            – saun4frsh
                            Jul 26 '14 at 16:58




                            1




                            1




                            What if app.config is added as a link to a project ?
                            – FrenkyB
                            Apr 8 '15 at 19:50




                            What if app.config is added as a link to a project ?
                            – FrenkyB
                            Apr 8 '15 at 19:50




                            1




                            1




                            This will only work if your connection string is an app setting, it will not work if to retrieve <connectionStrings> elements from app.config (which is what the OP is asking for!).
                            – BrainSlugs83
                            May 2 at 19:52




                            This will only work if your connection string is an app setting, it will not work if to retrieve <connectionStrings> elements from app.config (which is what the OP is asking for!).
                            – BrainSlugs83
                            May 2 at 19:52











                            27














                            Also check that you've included the System.Configuration dll under your references. Without it, you won't have access to the ConfigurationManager class in the System.Configuration namespace.






                            share|improve this answer


























                              27














                              Also check that you've included the System.Configuration dll under your references. Without it, you won't have access to the ConfigurationManager class in the System.Configuration namespace.






                              share|improve this answer
























                                27












                                27








                                27






                                Also check that you've included the System.Configuration dll under your references. Without it, you won't have access to the ConfigurationManager class in the System.Configuration namespace.






                                share|improve this answer












                                Also check that you've included the System.Configuration dll under your references. Without it, you won't have access to the ConfigurationManager class in the System.Configuration namespace.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jul 19 '12 at 7:49









                                Carl Heinrich Hancke

                                1,84012328




                                1,84012328























                                    19














                                    First Add a reference of System.Configuration to your page.



                                    using System.Configuration;


                                    Then According to your app.config get the connection string as follow.



                                    string conStr = ConfigurationManager.ConnectionStrings["Test"].ToString();


                                    That's it now you have your connection string in your hand and you can use it.






                                    share|improve this answer




























                                      19














                                      First Add a reference of System.Configuration to your page.



                                      using System.Configuration;


                                      Then According to your app.config get the connection string as follow.



                                      string conStr = ConfigurationManager.ConnectionStrings["Test"].ToString();


                                      That's it now you have your connection string in your hand and you can use it.






                                      share|improve this answer


























                                        19












                                        19








                                        19






                                        First Add a reference of System.Configuration to your page.



                                        using System.Configuration;


                                        Then According to your app.config get the connection string as follow.



                                        string conStr = ConfigurationManager.ConnectionStrings["Test"].ToString();


                                        That's it now you have your connection string in your hand and you can use it.






                                        share|improve this answer














                                        First Add a reference of System.Configuration to your page.



                                        using System.Configuration;


                                        Then According to your app.config get the connection string as follow.



                                        string conStr = ConfigurationManager.ConnectionStrings["Test"].ToString();


                                        That's it now you have your connection string in your hand and you can use it.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Aug 12 '16 at 17:36









                                        iliketocode

                                        5,42943046




                                        5,42943046










                                        answered Jan 16 '14 at 6:51









                                        Tapan kumar

                                        4,37711719




                                        4,37711719























                                            11














                                            //Get Connection from web.config file
                                            public static OdbcConnection getConnection()
                                            {
                                            OdbcConnection con = new OdbcConnection();
                                            con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString;
                                            return con;
                                            }





                                            share|improve this answer




























                                              11














                                              //Get Connection from web.config file
                                              public static OdbcConnection getConnection()
                                              {
                                              OdbcConnection con = new OdbcConnection();
                                              con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString;
                                              return con;
                                              }





                                              share|improve this answer


























                                                11












                                                11








                                                11






                                                //Get Connection from web.config file
                                                public static OdbcConnection getConnection()
                                                {
                                                OdbcConnection con = new OdbcConnection();
                                                con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString;
                                                return con;
                                                }





                                                share|improve this answer














                                                //Get Connection from web.config file
                                                public static OdbcConnection getConnection()
                                                {
                                                OdbcConnection con = new OdbcConnection();
                                                con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString;
                                                return con;
                                                }






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Aug 29 '17 at 17:08









                                                Massimiliano Kraus

                                                2,34741532




                                                2,34741532










                                                answered Apr 2 '15 at 7:56









                                                Gobind Mandal

                                                16122




                                                16122























                                                    6














                                                    Try this out



                                                    string abc = ConfigurationManager.ConnectionStrings["CharityManagement"].ConnectionString;





                                                    share|improve this answer




























                                                      6














                                                      Try this out



                                                      string abc = ConfigurationManager.ConnectionStrings["CharityManagement"].ConnectionString;





                                                      share|improve this answer


























                                                        6












                                                        6








                                                        6






                                                        Try this out



                                                        string abc = ConfigurationManager.ConnectionStrings["CharityManagement"].ConnectionString;





                                                        share|improve this answer














                                                        Try this out



                                                        string abc = ConfigurationManager.ConnectionStrings["CharityManagement"].ConnectionString;






                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited Aug 12 '16 at 17:36









                                                        iliketocode

                                                        5,42943046




                                                        5,42943046










                                                        answered Apr 29 '14 at 7:05









                                                        vishu9219

                                                        528512




                                                        528512























                                                            3














                                                            1) Create a new form and add this:



                                                            Imports System.Configuration
                                                            Imports Operaciones.My.MySettings

                                                            Public NotInheritable Class frmconexion

                                                            Private Shared _cnx As String
                                                            Public Shared Property ConexionMySQL() As String
                                                            Get
                                                            Return My.MySettings.Default.conexionbd
                                                            End Get
                                                            Private Set(ByVal value As String)
                                                            _cnx = value
                                                            End Set
                                                            End Property

                                                            End Class


                                                            then when you want to use the connection do this in ur form:



                                                             Private Sub frmInsert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

                                                            Dim cn As New MySqlConnection(frmconexion.ConexionMySQL)
                                                            cn.open()


                                                            and thats it. You will be connected to the DB and can do stuff.



                                                            This is for vb.net but the logic is the same.






                                                            share|improve this answer




























                                                              3














                                                              1) Create a new form and add this:



                                                              Imports System.Configuration
                                                              Imports Operaciones.My.MySettings

                                                              Public NotInheritable Class frmconexion

                                                              Private Shared _cnx As String
                                                              Public Shared Property ConexionMySQL() As String
                                                              Get
                                                              Return My.MySettings.Default.conexionbd
                                                              End Get
                                                              Private Set(ByVal value As String)
                                                              _cnx = value
                                                              End Set
                                                              End Property

                                                              End Class


                                                              then when you want to use the connection do this in ur form:



                                                               Private Sub frmInsert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

                                                              Dim cn As New MySqlConnection(frmconexion.ConexionMySQL)
                                                              cn.open()


                                                              and thats it. You will be connected to the DB and can do stuff.



                                                              This is for vb.net but the logic is the same.






                                                              share|improve this answer


























                                                                3












                                                                3








                                                                3






                                                                1) Create a new form and add this:



                                                                Imports System.Configuration
                                                                Imports Operaciones.My.MySettings

                                                                Public NotInheritable Class frmconexion

                                                                Private Shared _cnx As String
                                                                Public Shared Property ConexionMySQL() As String
                                                                Get
                                                                Return My.MySettings.Default.conexionbd
                                                                End Get
                                                                Private Set(ByVal value As String)
                                                                _cnx = value
                                                                End Set
                                                                End Property

                                                                End Class


                                                                then when you want to use the connection do this in ur form:



                                                                 Private Sub frmInsert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

                                                                Dim cn As New MySqlConnection(frmconexion.ConexionMySQL)
                                                                cn.open()


                                                                and thats it. You will be connected to the DB and can do stuff.



                                                                This is for vb.net but the logic is the same.






                                                                share|improve this answer














                                                                1) Create a new form and add this:



                                                                Imports System.Configuration
                                                                Imports Operaciones.My.MySettings

                                                                Public NotInheritable Class frmconexion

                                                                Private Shared _cnx As String
                                                                Public Shared Property ConexionMySQL() As String
                                                                Get
                                                                Return My.MySettings.Default.conexionbd
                                                                End Get
                                                                Private Set(ByVal value As String)
                                                                _cnx = value
                                                                End Set
                                                                End Property

                                                                End Class


                                                                then when you want to use the connection do this in ur form:



                                                                 Private Sub frmInsert_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

                                                                Dim cn As New MySqlConnection(frmconexion.ConexionMySQL)
                                                                cn.open()


                                                                and thats it. You will be connected to the DB and can do stuff.



                                                                This is for vb.net but the logic is the same.







                                                                share|improve this answer














                                                                share|improve this answer



                                                                share|improve this answer








                                                                edited Aug 12 '16 at 17:37









                                                                iliketocode

                                                                5,42943046




                                                                5,42943046










                                                                answered Nov 28 '12 at 4:13









                                                                OREO

                                                                311




                                                                311























                                                                    3














                                                                    Have you tried:



                                                                    var connection = new ConnectionFactory().GetConnection(
                                                                    ConfigurationManager.ConnectionStrings["Test"]
                                                                    .ConnectionString, DataBaseProvider);





                                                                    share|improve this answer




























                                                                      3














                                                                      Have you tried:



                                                                      var connection = new ConnectionFactory().GetConnection(
                                                                      ConfigurationManager.ConnectionStrings["Test"]
                                                                      .ConnectionString, DataBaseProvider);





                                                                      share|improve this answer


























                                                                        3












                                                                        3








                                                                        3






                                                                        Have you tried:



                                                                        var connection = new ConnectionFactory().GetConnection(
                                                                        ConfigurationManager.ConnectionStrings["Test"]
                                                                        .ConnectionString, DataBaseProvider);





                                                                        share|improve this answer














                                                                        Have you tried:



                                                                        var connection = new ConnectionFactory().GetConnection(
                                                                        ConfigurationManager.ConnectionStrings["Test"]
                                                                        .ConnectionString, DataBaseProvider);






                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited Mar 8 '17 at 10:22









                                                                        niico

                                                                        3,693104994




                                                                        3,693104994










                                                                        answered Jun 30 '11 at 15:24









                                                                        Vlad Bezden

                                                                        27.8k10124111




                                                                        27.8k10124111























                                                                            3














                                                                            I had the same Issue. my solution was built up from two projects. A Class library and a website referencing to the class library project. the problem was that i was trying to access the App.config in my Class library project but the system was searching in Web.config of the website. I put the connection string inside Web.config and ... problem solved!



                                                                            The main reason was that despite ConfigurationManager was used in another assembly it was searching inside the runnig project .






                                                                            share|improve this answer


























                                                                              3














                                                                              I had the same Issue. my solution was built up from two projects. A Class library and a website referencing to the class library project. the problem was that i was trying to access the App.config in my Class library project but the system was searching in Web.config of the website. I put the connection string inside Web.config and ... problem solved!



                                                                              The main reason was that despite ConfigurationManager was used in another assembly it was searching inside the runnig project .






                                                                              share|improve this answer
























                                                                                3












                                                                                3








                                                                                3






                                                                                I had the same Issue. my solution was built up from two projects. A Class library and a website referencing to the class library project. the problem was that i was trying to access the App.config in my Class library project but the system was searching in Web.config of the website. I put the connection string inside Web.config and ... problem solved!



                                                                                The main reason was that despite ConfigurationManager was used in another assembly it was searching inside the runnig project .






                                                                                share|improve this answer












                                                                                I had the same Issue. my solution was built up from two projects. A Class library and a website referencing to the class library project. the problem was that i was trying to access the App.config in my Class library project but the system was searching in Web.config of the website. I put the connection string inside Web.config and ... problem solved!



                                                                                The main reason was that despite ConfigurationManager was used in another assembly it was searching inside the runnig project .







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Mar 29 '17 at 8:51









                                                                                AmiNadimi

                                                                                1,62211732




                                                                                1,62211732























                                                                                    2














                                                                                    string sTemp = System.Configuration.ConfigurationManager.ConnectionStrings["myDB In app.config"].ConnectionString;





                                                                                    share|improve this answer




























                                                                                      2














                                                                                      string sTemp = System.Configuration.ConfigurationManager.ConnectionStrings["myDB In app.config"].ConnectionString;





                                                                                      share|improve this answer


























                                                                                        2












                                                                                        2








                                                                                        2






                                                                                        string sTemp = System.Configuration.ConfigurationManager.ConnectionStrings["myDB In app.config"].ConnectionString;





                                                                                        share|improve this answer














                                                                                        string sTemp = System.Configuration.ConfigurationManager.ConnectionStrings["myDB In app.config"].ConnectionString;






                                                                                        share|improve this answer














                                                                                        share|improve this answer



                                                                                        share|improve this answer








                                                                                        edited Dec 8 '12 at 12:22









                                                                                        j0k

                                                                                        20.1k136575




                                                                                        20.1k136575










                                                                                        answered Dec 8 '12 at 12:04









                                                                                        khatami

                                                                                        211




                                                                                        211























                                                                                            1














                                                                                            You can fetch the connection string by using below line of code -



                                                                                            using System; using System.Configuration;

                                                                                            var connectionString=ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;


                                                                                            Here is a reference :
                                                                                            Connection String from App.config






                                                                                            share|improve this answer

















                                                                                            • 1




                                                                                              I did the same as u said but same null reference error I am getting.
                                                                                              – Enigmatic Mind
                                                                                              Sep 13 '16 at 18:41
















                                                                                            1














                                                                                            You can fetch the connection string by using below line of code -



                                                                                            using System; using System.Configuration;

                                                                                            var connectionString=ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;


                                                                                            Here is a reference :
                                                                                            Connection String from App.config






                                                                                            share|improve this answer

















                                                                                            • 1




                                                                                              I did the same as u said but same null reference error I am getting.
                                                                                              – Enigmatic Mind
                                                                                              Sep 13 '16 at 18:41














                                                                                            1












                                                                                            1








                                                                                            1






                                                                                            You can fetch the connection string by using below line of code -



                                                                                            using System; using System.Configuration;

                                                                                            var connectionString=ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;


                                                                                            Here is a reference :
                                                                                            Connection String from App.config






                                                                                            share|improve this answer












                                                                                            You can fetch the connection string by using below line of code -



                                                                                            using System; using System.Configuration;

                                                                                            var connectionString=ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;


                                                                                            Here is a reference :
                                                                                            Connection String from App.config







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered Oct 17 '13 at 8:45









                                                                                            somesh

                                                                                            1,8382129




                                                                                            1,8382129








                                                                                            • 1




                                                                                              I did the same as u said but same null reference error I am getting.
                                                                                              – Enigmatic Mind
                                                                                              Sep 13 '16 at 18:41














                                                                                            • 1




                                                                                              I did the same as u said but same null reference error I am getting.
                                                                                              – Enigmatic Mind
                                                                                              Sep 13 '16 at 18:41








                                                                                            1




                                                                                            1




                                                                                            I did the same as u said but same null reference error I am getting.
                                                                                            – Enigmatic Mind
                                                                                            Sep 13 '16 at 18:41




                                                                                            I did the same as u said but same null reference error I am getting.
                                                                                            – Enigmatic Mind
                                                                                            Sep 13 '16 at 18:41











                                                                                            1














                                                                                            It seems like problem is not with reference, you are getting connectionstring as null so please make sure you have added the value to the config file your running project meaning the main program/library that gets started/executed first.






                                                                                            share|improve this answer


























                                                                                              1














                                                                                              It seems like problem is not with reference, you are getting connectionstring as null so please make sure you have added the value to the config file your running project meaning the main program/library that gets started/executed first.






                                                                                              share|improve this answer
























                                                                                                1












                                                                                                1








                                                                                                1






                                                                                                It seems like problem is not with reference, you are getting connectionstring as null so please make sure you have added the value to the config file your running project meaning the main program/library that gets started/executed first.






                                                                                                share|improve this answer












                                                                                                It seems like problem is not with reference, you are getting connectionstring as null so please make sure you have added the value to the config file your running project meaning the main program/library that gets started/executed first.







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered Jan 9 '14 at 6:17









                                                                                                Chandra Malla

                                                                                                2,0591411




                                                                                                2,0591411























                                                                                                    1














                                                                                                    It is possible that the OP in this question is trying to use an App.Config within a dll.



                                                                                                    In this case, the code is actually trying to access the App.Config of the executable and not the dll. Since the name is not found, you get a Null returned, hence the exception shown.



                                                                                                    The following post may be helpful:
                                                                                                    ConnectionString from app.config of a DLL is null






                                                                                                    share|improve this answer























                                                                                                    • my case exactly, thanks
                                                                                                      – user1451111
                                                                                                      Nov 2 '17 at 9:30
















                                                                                                    1














                                                                                                    It is possible that the OP in this question is trying to use an App.Config within a dll.



                                                                                                    In this case, the code is actually trying to access the App.Config of the executable and not the dll. Since the name is not found, you get a Null returned, hence the exception shown.



                                                                                                    The following post may be helpful:
                                                                                                    ConnectionString from app.config of a DLL is null






                                                                                                    share|improve this answer























                                                                                                    • my case exactly, thanks
                                                                                                      – user1451111
                                                                                                      Nov 2 '17 at 9:30














                                                                                                    1












                                                                                                    1








                                                                                                    1






                                                                                                    It is possible that the OP in this question is trying to use an App.Config within a dll.



                                                                                                    In this case, the code is actually trying to access the App.Config of the executable and not the dll. Since the name is not found, you get a Null returned, hence the exception shown.



                                                                                                    The following post may be helpful:
                                                                                                    ConnectionString from app.config of a DLL is null






                                                                                                    share|improve this answer














                                                                                                    It is possible that the OP in this question is trying to use an App.Config within a dll.



                                                                                                    In this case, the code is actually trying to access the App.Config of the executable and not the dll. Since the name is not found, you get a Null returned, hence the exception shown.



                                                                                                    The following post may be helpful:
                                                                                                    ConnectionString from app.config of a DLL is null







                                                                                                    share|improve this answer














                                                                                                    share|improve this answer



                                                                                                    share|improve this answer








                                                                                                    edited May 23 '17 at 12:26









                                                                                                    Community

                                                                                                    11




                                                                                                    11










                                                                                                    answered Jun 29 '15 at 21:15









                                                                                                    Andrew

                                                                                                    439519




                                                                                                    439519












                                                                                                    • my case exactly, thanks
                                                                                                      – user1451111
                                                                                                      Nov 2 '17 at 9:30


















                                                                                                    • my case exactly, thanks
                                                                                                      – user1451111
                                                                                                      Nov 2 '17 at 9:30
















                                                                                                    my case exactly, thanks
                                                                                                    – user1451111
                                                                                                    Nov 2 '17 at 9:30




                                                                                                    my case exactly, thanks
                                                                                                    – user1451111
                                                                                                    Nov 2 '17 at 9:30











                                                                                                    1














                                                                                                    First you have to add System.Configuration reference to your project and then use below code to get connection string.



                                                                                                    _connectionString = ConfigurationManager.ConnectionStrings["MYSQLConnection"].ConnectionString.ToString();





                                                                                                    share|improve this answer




























                                                                                                      1














                                                                                                      First you have to add System.Configuration reference to your project and then use below code to get connection string.



                                                                                                      _connectionString = ConfigurationManager.ConnectionStrings["MYSQLConnection"].ConnectionString.ToString();





                                                                                                      share|improve this answer


























                                                                                                        1












                                                                                                        1








                                                                                                        1






                                                                                                        First you have to add System.Configuration reference to your project and then use below code to get connection string.



                                                                                                        _connectionString = ConfigurationManager.ConnectionStrings["MYSQLConnection"].ConnectionString.ToString();





                                                                                                        share|improve this answer














                                                                                                        First you have to add System.Configuration reference to your project and then use below code to get connection string.



                                                                                                        _connectionString = ConfigurationManager.ConnectionStrings["MYSQLConnection"].ConnectionString.ToString();






                                                                                                        share|improve this answer














                                                                                                        share|improve this answer



                                                                                                        share|improve this answer








                                                                                                        edited Mar 14 '17 at 15:32









                                                                                                        Tasos K.

                                                                                                        6,57552848




                                                                                                        6,57552848










                                                                                                        answered Mar 14 '17 at 15:26









                                                                                                        SagarJaybhay

                                                                                                        113




                                                                                                        113























                                                                                                            1














                                                                                                            This worked for me:



                                                                                                            string connection = System.Configuration.ConfigurationManager.ConnectionStrings["Test"].ConnectionString;


                                                                                                            Outputs:




                                                                                                            Data Source=.;Initial Catalog=OmidPayamak;IntegratedSecurity=True"







                                                                                                            share|improve this answer




























                                                                                                              1














                                                                                                              This worked for me:



                                                                                                              string connection = System.Configuration.ConfigurationManager.ConnectionStrings["Test"].ConnectionString;


                                                                                                              Outputs:




                                                                                                              Data Source=.;Initial Catalog=OmidPayamak;IntegratedSecurity=True"







                                                                                                              share|improve this answer


























                                                                                                                1












                                                                                                                1








                                                                                                                1






                                                                                                                This worked for me:



                                                                                                                string connection = System.Configuration.ConfigurationManager.ConnectionStrings["Test"].ConnectionString;


                                                                                                                Outputs:




                                                                                                                Data Source=.;Initial Catalog=OmidPayamak;IntegratedSecurity=True"







                                                                                                                share|improve this answer














                                                                                                                This worked for me:



                                                                                                                string connection = System.Configuration.ConfigurationManager.ConnectionStrings["Test"].ConnectionString;


                                                                                                                Outputs:




                                                                                                                Data Source=.;Initial Catalog=OmidPayamak;IntegratedSecurity=True"








                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited Aug 29 '17 at 17:07









                                                                                                                Massimiliano Kraus

                                                                                                                2,34741532




                                                                                                                2,34741532










                                                                                                                answered Feb 13 '17 at 7:45









                                                                                                                Talha Imam

                                                                                                                191314




                                                                                                                191314























                                                                                                                    0














                                                                                                                    I referenced System.Configuration library and I have the same error.
                                                                                                                    The debug files had not their app.config, create manually this file.
                                                                                                                    The error is, I solved this copying the file "appname.exe.config" in debug folder. The IDE was not create the file.






                                                                                                                    share|improve this answer




























                                                                                                                      0














                                                                                                                      I referenced System.Configuration library and I have the same error.
                                                                                                                      The debug files had not their app.config, create manually this file.
                                                                                                                      The error is, I solved this copying the file "appname.exe.config" in debug folder. The IDE was not create the file.






                                                                                                                      share|improve this answer


























                                                                                                                        0












                                                                                                                        0








                                                                                                                        0






                                                                                                                        I referenced System.Configuration library and I have the same error.
                                                                                                                        The debug files had not their app.config, create manually this file.
                                                                                                                        The error is, I solved this copying the file "appname.exe.config" in debug folder. The IDE was not create the file.






                                                                                                                        share|improve this answer














                                                                                                                        I referenced System.Configuration library and I have the same error.
                                                                                                                        The debug files had not their app.config, create manually this file.
                                                                                                                        The error is, I solved this copying the file "appname.exe.config" in debug folder. The IDE was not create the file.







                                                                                                                        share|improve this answer














                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer








                                                                                                                        edited Aug 12 '16 at 17:37









                                                                                                                        iliketocode

                                                                                                                        5,42943046




                                                                                                                        5,42943046










                                                                                                                        answered Jun 16 '15 at 18:20









                                                                                                                        jjcaicedo

                                                                                                                        1




                                                                                                                        1























                                                                                                                            0














                                                                                                                            I solved the problem by using the index to read the string and checking one by one. Reading using the name still gives the same error.

                                                                                                                            I have the problem when I develop a C# window application, I did not have the problem in my asp.net application. There must be something in the setting which is not right.






                                                                                                                            share|improve this answer


























                                                                                                                              0














                                                                                                                              I solved the problem by using the index to read the string and checking one by one. Reading using the name still gives the same error.

                                                                                                                              I have the problem when I develop a C# window application, I did not have the problem in my asp.net application. There must be something in the setting which is not right.






                                                                                                                              share|improve this answer
























                                                                                                                                0












                                                                                                                                0








                                                                                                                                0






                                                                                                                                I solved the problem by using the index to read the string and checking one by one. Reading using the name still gives the same error.

                                                                                                                                I have the problem when I develop a C# window application, I did not have the problem in my asp.net application. There must be something in the setting which is not right.






                                                                                                                                share|improve this answer












                                                                                                                                I solved the problem by using the index to read the string and checking one by one. Reading using the name still gives the same error.

                                                                                                                                I have the problem when I develop a C# window application, I did not have the problem in my asp.net application. There must be something in the setting which is not right.







                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered Oct 26 '17 at 7:37









                                                                                                                                dew17

                                                                                                                                1




                                                                                                                                1






























                                                                                                                                    draft saved

                                                                                                                                    draft discarded




















































                                                                                                                                    Thanks for contributing an answer to Stack Overflow!


                                                                                                                                    • Please be sure to answer the question. Provide details and share your research!

                                                                                                                                    But avoid



                                                                                                                                    • Asking for help, clarification, or responding to other answers.

                                                                                                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                                    To learn more, see our tips on writing great answers.





                                                                                                                                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                                                                                                                    Please pay close attention to the following guidance:


                                                                                                                                    • Please be sure to answer the question. Provide details and share your research!

                                                                                                                                    But avoid



                                                                                                                                    • Asking for help, clarification, or responding to other answers.

                                                                                                                                    • Making statements based on opinion; back them up with references or personal experience.


                                                                                                                                    To learn more, see our tips on writing great answers.




                                                                                                                                    draft saved


                                                                                                                                    draft discarded














                                                                                                                                    StackExchange.ready(
                                                                                                                                    function () {
                                                                                                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6536715%2fget-connection-string-from-app-config%23new-answer', 'question_page');
                                                                                                                                    }
                                                                                                                                    );

                                                                                                                                    Post as a guest















                                                                                                                                    Required, but never shown





















































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown

































                                                                                                                                    Required, but never shown














                                                                                                                                    Required, but never shown












                                                                                                                                    Required, but never shown







                                                                                                                                    Required, but never shown







                                                                                                                                    Popular posts from this blog

                                                                                                                                    鏡平學校

                                                                                                                                    ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

                                                                                                                                    Why https connections are so slow when debugging (stepping over) in Java?