locked
Change server path in web api RRS feed

  • Question

  • User746671234 posted

    Hello, I am using ASP.NET 2013 and I created API there by connecting to local server.  Now I need to make it online.  I can't check locally by connecting my online SQL Server because it's on vps.  So I change server path in web.config with my vps dbpath.  But still it's not working.  Can anyone tell me how to change it.  I am posting my web.config path.

     <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <connectionStrings>
        <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-apidirect-20200507042821.mdf;Initial Catalog=aspnet-apidirect-20200507042821;Integrated Security=True" providerName="System.Data.SqlClient" />
        <add name="eternityEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DESKTOP-OFGME7K;initial catalog=eternity;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
        <!-- <add name="eternityEntities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=S198-12-154-229\MSSQLSERVER2014;User ID=eternity;password=Qwer@#1111;initial catalog=eternity;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />-->
      </connectionStrings>

    In last commented line I tried to change path.  But it's not working though

    Friday, May 8, 2020 10:04 AM

All replies

  • User475983607 posted

    You should know your SQL server name/IP and login credentials.  Use Visual Studio's "SQL Server Object Explorer" or "Server Explorer" to connect to your "online SQL Server".  Once you make the connection you can copy connection string from the properties window and paste it into your web.config.

    Friday, May 8, 2020 10:40 AM
  • User746671234 posted

    I cannot connect it from local.  I already told you that it's on VPS.

    Friday, May 8, 2020 10:41 AM
  • User475983607 posted

    I cannot connect it from local.  I already told you that it's on VPS.

    Running SQL server on a VPS is very very common.  Can you explain why you are unable to connect to the VPS running SQL server?  Is it because SQL server is not installed and configured on your VPS?

    Friday, May 8, 2020 10:56 AM
  • User746671234 posted

    SQL Server is already installed on our vps.  But I haven't installed asp.net on there.  So I am working on my local machine.

    Friday, May 8, 2020 11:06 AM
  • User746671234 posted

    I found the solution.  It was my mistake.

    Friday, May 8, 2020 11:58 AM