none
Web.config - Visual Studio 2010 Pro vs 2015 Community

    Question

  • Hello,

    I'm currently using a System.Data.SqlClient connection string in VS 2010 Pro in my web.config file located here: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config

    Using this I'm able to authenticate/run the application in a browser. However when I try the same application in VS 2015 I'm unable to authenticate. It's as if 2015 is not using the the web.config at all. The format of my string is like this:

        <connectionStrings>
            <remove name="LocalSqlServer"/>
            <add name="BioAffidavit"
                     providerName="System.Data.SqlClient"
                     connectionString="Data Source=zzzzzzzzzzzz,15026;Initial Catalog=zzzzzzzzzzzzzzz;User ID=aaaaaaaa;Password=aaaaaaaaa;MultipleActiveResultSets=True" />
        </connectionStrings>

    Does 2015 require a different format or different file location?

    Thanks,

    Jon

    Wednesday, August 17, 2016 3:03 PM

All replies

  • Hi Jbirdmotox,

    In my side VS2015, I could connect to SQL Server Database successfully. Please refer to the following code.

    Connect string in Web.config:

      <connectionStrings>
      <add name="ConnectionStringName"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=****;Initial Catalog=results;persist security info=true;user id=***;password=***;pooling=false" />
        
      </connectionStrings>

    And test code that to verify whether this connect string could connect to database successfully:

                string myvar1 = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ToString();
                SqlConnection conn = new SqlConnection(myvar1);
                try
                {
                    conn.Open();
                    Response.Write("connect successfully");
                }
                catch (Exception ex)
                {
                    Response.Write("connect failed");
                }

    As far as I know, I suggest you do not use local database, which may be has some problems in moving project. The following MSDN document is about how to configure connection strings for ASP.NET in Web Applications. Please refer to the connection string format from the following link:

    https://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx

    Sincerely,

    Oscar




    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    • Proposed as answer by GoyourGod Sunday, August 21, 2016 11:36 AM
    • Marked as answer by qing__Moderator Thursday, August 25, 2016 10:55 AM
    • Unmarked as answer by qing__Moderator Thursday, September 01, 2016 9:47 AM
    Thursday, August 18, 2016 6:17 AM
    Moderator
  • Hi jbirdmotox,

    Has your issue been resolved? Please feel free to let me know your latest result.

    If you have resolved your issue, would you please share your solution here?

    If a reply that help you resolve the issue, would you please mark it as answer which could help others who encountered the same issue as you.

    Sincerely,

    Oscar


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Monday, August 22, 2016 8:14 AM
    Moderator