Migration to Visual Studio 2013, issue with connecting Database

Discussion in 'Windows / IIS' started by Senor Engineer, Sep 26, 2014.

  1. I need a big help from the community.

    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-SITENAME-20140111111111.mdf;Initial Catalog=aspnet-SITENAME-20140111111111;Integrated Security=True" providerName="System.Data.SqlClient" />

    changed to :

    <add name="DefaultConnection" connectionString="Data Source=tcp:sql2k***.discountasp.net;Initial Catalog=SQL2008_******_restsearch;User ID=SQL2008_******_******;Password=*******;" providerName="System.Data.SqlClient" />

    I believe DefaultConnection is using for mdb file, and I think it's applciation database that has Membership database, Not sure how I hide it if I do not point in production. It works in my local database but when I upload the code, it breaks. I copied .mdf file under App_Data, but still doesn't work. Any help here?

    I think below should be alright, or please let me know if I have to change. Currently the site is down and I would like to get it up and running, sorry I got struck with database connection itself.

    <add name="dbABCConnectionString" connectionString="Data Source=tcp:sql2k***.discountasp.net;Initial Catalog=SQL2008_***********;User ID=SQL2008_*************;Password=*******;" providerName="System.Data.SqlClient" />

    <add name="SQL2008_*****_projectEntities" connectionString="metadata=res://*/NRB.csdl|res://*/NRB.ssdl|res://*/NRB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=Data Source=tcp:sql2k***.discountasp.net;Initial Catalog=SQL2008_***********;User ID=SQL2008_*************;Password=*******;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
     
  2. martino

    martino DiscountASP.NET Staff

    The mdf file I believe is a SQL Express database that we don't support in our environment.

    Since it does appear that you have a SQL database hosted with us. What you first will need to do is backup your current SQL database (Just in case something goes wrong you can always revert back to it.)

    Then use the SQL Attached tool in our control panel to restore the .mdf file into the SQL database you have hosted with us. Once you did that update the connection string to connect to our SQL database.

    Read our knowledge base article on how to use the SQL backup tool and how to use the SQL Attached tool in our control panel here: https://support.discountasp.net/KB/a188/sql-2008-management-tools.aspx
     
  3. Looks like I have an issue at the moment with connecting to SQL Server hosted on your end. It worked earlier (same connection string used in Visual Studio 2008). Only difference was to use EntityModel at this time, any help? Would you mind to check if the Windows Server 2012 has remote connection to the database server that is hosted by you? Or any thing that you can help me correct this issue, I would really appreciate. I created support ticket as well (with name : Upgrading from Visual Studio 2008 to Visual Studio 2013).
     
  4. When I use the code below, I get the error. It works good in my local database (same database name as production).

    return dbContext.TableUser.Where(el => ((el.Name == nm) && (el.id== id))).FirstOrDefault();

    breaks at the above line.

    An exception of type 'System.Data.Entity.Core.EntityException' occurred in mscorlib.dll but was not handled in user code

    Additional information: The underlying provider failed on Open.

    {"The underlying provider failed on Open."}
     
  5. The production database is same as before (only difference is website code has been changed). Hope that helps.
     
  6. martino

    martino DiscountASP.NET Staff

  7. martino

    martino DiscountASP.NET Staff

  8. martino

    martino DiscountASP.NET Staff

    Your issue isn't a network issue. We have demonstrated over the ticket you have opened that the connection to the SQL database from our web server is possible. Also, in order to connect to our SQL database you must use SQL Server Authentication with the primary SQL database user you have for your SQL database and the password for that SQL database user.

    Also, make sure that you have attached the mdf file onto your SQL database that you're connecting to on our hosting environment. Then read the articles carefully that I have provided to you and take the time to trouble shoot the issue.

    Also remember that just because it works locally on your computer doesn't mean it's going to work on our web server once you upload it. There could be certain settings that you might need to change in order for your web application to work in our web server. You might be missing a dll file or you might be using an incorrect setting in your web application. What exactly you're missing or what setting is incorrect we would not know but those web page articles I provided above might point you in the right direction.
     
    mjp likes this.
  9. I fixed the error, thank you !!! The issue was with connection to database from my Entity Model.
     
    RayH, mjp and martino like this.

Share This Page