locked
connection string doesnot work on server RRS feed

  • Question

  • User1398839915 posted

    I tried to host my mvc app using entity framework on the server.

    There is a problem with the connection string.

    on my developer machine it was 

    <connectionStrings>
        <add name="myDBEntities" connectionString="metadata=res://*/myEDM.csdl|res://*/myEDM.ssdl|res://*/myEDM.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=DESKTOP-xxxxxx;initial catalog=myDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
      
      </connectionStrings>

    After hosting , I changed this to 

     <connectionStrings>
        <add name="myDBEntities" connectionString="metadata=res://*/myEDM.csdl|res://*/myEDM.ssdl|res://*/myEDM.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=xxxxxxxx;initial catalog=myDB;User ID=userid;password=pwd;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"providerName="System.Data.EntityClient" />
      </connectionStrings>

    The datasouce , userid and password are entered correctly, as I tried to connect from Management Studio SQL and it was sucessful.

    But when tried to change the connection string   in web.config file of server , it shows 500 internal server error.

    What is that Im missing? Is my changed connection string correct? please help

    Friday, July 10, 2020 8:53 AM

Answers

  • User753101303 posted

    Hi,

    If using a user id and password remove the "Integrated Security=True" part from your connection string.

    http 500 means you have a server side error. your hosting service should likely log those messages somewhere so that you can access them...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2020 9:04 AM
  • User475983607 posted

    There really is not much forum members can do if you do not know your connection string fields. 

    All you need is the database server, database name, and credentials.  Usually, you can get this information by logging into your hosting account.  Once you have the database connection info you can use Visual Studio to connect (or SSMS) to connect to the DB.   In Visual Studio just click the View dropdown menu and select SQL Server object Explorer.  Then make a new connection with the connection info from your account.  Once you connect, then you can copy the connection string from the properties window.   Very simple.

    It's a different story if you did not create a database.  Anyway, connect your host for assistance.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2020 11:19 AM

All replies

  • User753101303 posted

    Hi,

    If using a user id and password remove the "Integrated Security=True" part from your connection string.

    http 500 means you have a server side error. your hosting service should likely log those messages somewhere so that you can access them...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2020 9:04 AM
  • User1398839915 posted

    tried but didnot work.  

    datasource =server number generated when database was created on server.

    usename= myuser (created when database was created on server)

    password=mypwd (created when database was created on server)

    added providerName="System.Data.EntityClient"

    Removed Integrated Security=True

    These are the changes made in my connectionstring in both web.config files. still not working

    Friday, July 10, 2020 10:31 AM
  • User475983607 posted

    There really is not much forum members can do if you do not know your connection string fields. 

    All you need is the database server, database name, and credentials.  Usually, you can get this information by logging into your hosting account.  Once you have the database connection info you can use Visual Studio to connect (or SSMS) to connect to the DB.   In Visual Studio just click the View dropdown menu and select SQL Server object Explorer.  Then make a new connection with the connection info from your account.  Once you connect, then you can copy the connection string from the properties window.   Very simple.

    It's a different story if you did not create a database.  Anyway, connect your host for assistance.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2020 11:19 AM
  • User753101303 posted

    So if the quick guess doesn't work it would be mcuh better to get the exact error message. Do you have access to some logs ? Usually :
    - by default 500.0 are exceptions which should be written to the event log and likely made available somewhere by your hosting server
    - if not finding anything I would look at the web server log (for example 500.19 is a problem wtih the config file)

    Friday, July 10, 2020 12:30 PM