I’m having a problem with my connection string after deploying. My site, www.coopersystems.net, is hosted by Godaddy. I’m using Visual Web Developer Express 2012 using E-Code First. Godaddy gave me the following connection string information:
Data Source=MyDatabaseName.db.10000000.hostedresource.com; Initial Catalog=MyDatabaseName; User ID=MyDatabaseName; Password='MyDatabasePassword';
I then used this info to change my connection string to the following:
<connectionStrings>
<add name="ApplicationServices" connectionString="Data Source=MyDatabaseName.db. 10000000.hostedresource.com; Initial Catalog = MyDatabaseName; User ID=MyDatabaseName; Password=’MyDayabasePassword’;Integrated Security=True" providerName="System.Data.SqlClient" />
<remove name="LocalSqlServer"/>
<add name="ApplicationServices" connectionString="Data Source=MyDatabaseName.db. 10000000.hostedresource.com; Initial Catalog = MyDatabaseName; User ID=MyDatabaseName; Password='MyDatabasePassword';Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
The default page shows up fine but clicking on the tabs that should load other pages does not work. The page seems to hang for a while then the error page shows with error: “We’re sorry, we’ve hit an unexpected error. Click here it you’d like to go back and try again”.
My first question is:
1: If my connection string is wrong, would my default page still load? I ask this because when I tried changing keyword/value the home page would not load.
2: Is there something other than my connection string that I may be able to check?
3: How can I solve this problem?
Any suggestions or help would be greatly appreciated. I’m going on my second week of trying to get Godaddy to help and using their forums. Nothing has worked yet.
Latest attempts:
So I fixed the password quotes and had godaddy configured the config file to show the error message..
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I assume the server not found to mean that I provided the wrong name for a server on the Web Publish wizard so I’ve been trying different combinations of Server Name, Site Path, and Destination URL.. I got the site deployed with a few combinations of those values but the links still wont work.
Is there a configuration that maybe I should’ve done before using the “Publish” function of Web Developer Express 2012? I am out of ideas and Godaddy can’t help.
After one week of trying I decided to try to connect to the database using IIS 7.5. I can't connect with this either so I guess If I can solve connecting to the site or database with IIS I should be able to solve my other problems. Please help if you can. Thanks.
Try removing the single quotes around the password:
Password=MyDatabasePassword
Turns out that my ISP is blocking port 1433. No mater what I do I can't access the database.
Related
I'm trying to develop my first web app. I deployed my app to the server host (SmarterAsp.net) and kept having trouble connecting to my app's database.
I tried connecting to the app database locally (running my app in my Visual Studio with IIS Express) with the smarterasp username and password and it connected to my local database. I even took out the connection string entirely and it still connected to my local database.
I tried connecting to my app database in SSMS to see if I have the wrong user name and password and it worked perfectly fine. I'm at a loss to figure out where I'm going wrong
Here are my connection strings
<add name="TimeSheetDbContext"
connectionString="Data Source=data source.net;Initial Catalog=catalog;User Id=user id;Password=password;MultipleActiveResultSets=True "
providerName="System.Data.SqlClient" />
<add name="DefaultConnectionEntities"
connectionString="metadata=res://*/VerifyCompanyCeo.csdl|res://*/VerifyCompanyCeo.ssdl|res://*/VerifyCompanyCeo.msl;provider=System.Data.SqlClient;provider connection string=';data source=data source;initial catalog=catalog;integrated security=false;User Id=user id;Password=password;MultipleActiveResultSets=True;App=EntityFramework';"
providerName="System.Data.EntityClient" />
Here is my database connection code code in my controllers
private TimeSheetDbContext db = new TimeSheetDbContext();
I tried to clear the Visual Studio cache but that too didn't help. Any help would be greatly appreciated thanks so much
I'm trying very hard to go from Entity Framework 5 to 6. After solving a SimpleMembership issue that was in my Web.config I have the following error :
Login failed for user 'sa'
Anytime I try to reach a tab (on my page) that requires SQL Data display.
Here is my connectionStrings (the relevant one being DefaultConnection) :
<connectionStrings>
<add name="DefaultConnection" connectionString="packet size=4096;Data Source=MMSDEVNEW\SQL2008;Initial Catalog=CRAV34;User ID=sa;Password=*****;" providerName="System.Data.SqlClient" />
<add name="CRAV34Entities"
connectionString="metadata=res://*/Models.CRA.csdl|
res://*/Models.CRA.ssdl|
res://*/Models.CRA.msl;
provider=System.Data.SqlClient;
provider connection string="data source=MMSDEVNEW\SQL2008;
initial catalog=CRAV34;
persist security info=True;
user id=sa;
multipleactiveresultsets=True;
App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
I read that this may be a permission issue or changing the security properties from the SQL Server Management Studio to "SQL Server and Windows Authentication mode". All of this has been done. The login and password are valid in the connectionString.
What could possibly cause this issue?
Just add Integrated security=true in your connection string
<add name="DbConnectionString" connectionString="Data Source=LENOVO\SQL2K12;Initial Catalog=EFCodeFirst;User ID=sa; Password=xxxxx;Integrated security=true" providerName="System.Data.SqlClient" />
If you are sure the SQL Server is in "mixed mode", and that the password is correct for the "sa" account, I can only suggest it to be that the "sa" user doesn't have access to the named database.
In SQL Management Studio, expand the database branch, then security, then users, and check if the "sa" user appears in the list.
The best way to diagnose this error is to try and connect to the database server using SQL Management studio, logging in AS the user in the connection string.
If you can log in, see if you can see your target database in the tree on the left.
If you can, try and open the database node and see if you can see all the tables.
If you can, see if you can run a select query against one of those tables.
If you can do ALL of the above, then it's NOT an issue with SQL server, but rather your connection string.
However, I've never seen that error come up when it's NOT a SQL configuration issue.
Try it with SQL Management Studio from the same machine you're code is running and it should give you more information about what's wrong.
Edit your post / reply to this answer if this doesn't solve it, explain what you tried and what the result(s) were, and I'll update the answer to reflect what I'd try next!
edit 1:
Try changing your connection string to the following:
packet size=4096;Server=MMSDEVNEW\SQL2008;Database=CRAV34;User ID=sa;Password=*****;
edit 2:
If this connection string is valid, it could actually be the second one that is causing a problem, as EF would likely choose that one unless explicitly told to use the "default" one.
As this second connection string doesn't have a password specified, it might be this that's causing the error.
Can you try it again with a password specified?
If you are using Integrated security=true, it could be the account you are running under does not have permission.
Try opening Visual Studio running as a different User. ( the user has permission on the database).
Use Shift and right click on the pinned Visual Studio menu.
Please help me a bit...
I have a domain with a web page, coded and compiled in VS2013, works like a charm... Then I decided to add a database, so I wrote one (ms sql). However, later when I deployed the project I can only watch the _Layout.cshtml file online, local everything looks perfect. What might be the problem? I've tried re-order some settings and scripts, but without success. A supplementary question, can the Connectionstring cause this? I've been having some problems with that nasty row.
This is my connectionstring for deploy:
<add name="20066_name" connectionString="Data Source=name-20066.mssql.domainaddress.com;Initial Catalog=20066-name;Integrated Security Info=True;User Id=secret;Password=secret" providerName="System.Data.SqlClient" />
So locally works fine with a local database, or using the connection string's remote database?
Try using the remote connection string with the local deployment and see if it connects. If it does, then you need to check the properties on the publish dialog. There is an option for altering the connection strings when you deploy (you might have heard this process as web.config transformation), so make sure that you send the correct connection string to the remote web server.
The connection string seems ok. You can experiment with more options though. Check the following link for ideas http://www.connectionstrings.com/sql-server/
I have a simple mvc web site (using the VS internet template) on azurewebsites talking to a SQL Azure database in the same data center. The database at this time is just to do the built-in SimpleMembership Provider. I have already switched from the default App_Data mdf file to Azure SQL. It works fine, but sometimes after a while, it would give:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL
Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)
with a long message:
SQLExpress database file auto-creation error:
The connection string specifies a local Sql Server Express instance
using a database location within the application's App_Data directory.
The provider attempted to automatically create the application
services database because the provider determined that the database
does not exist. The following configuration requirements are necessary
to successfully check for existence of the application services
database and automatically create the application services database:
But I do not have a connection string using SQL Server Express!
Restarting the web site immediately does not remove the error.
Without changing anything and restarting the web site 15 minutes later give:
502 - Web server received an invalid response while acting as a
gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be
displayed. When the Web server (while acting as a gateway or proxy)
contacted the upstream content server, it received an invalid response
from the content server.
Previously, I could restore the website back to working order by just re-publshing from VS. But for the last hour I have tried and tried and I cannot get the web site to work again.
What is the problem about SQL Server Express really about?
My connection string section contains:
<connectionStrings>
<add name="DefaultConnection" connectionString="Server=tcp:sabl6h4---.database.windows.net,1433;Database=MVC;User ID=test#sabl6h4---;Password=----;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.SqlClient" />
<add name="Entities" connectionString="metadata=res://*/Data.Model1.csdl|res://*/Data.Model1.ssdl|res://*/Data.Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=sabl6h4---.database.windows.net;initial catalog=MVC;user id=test;password=----;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Just to be sure, I copied and pasted sabl6h4---.database.windows.net into SSMS and connected using login test and it opened the database without problem.
One day later: I created a new azurewebsite and published the exact same project and same web.config. It works fine without problems. After some minutes, the exact same error occurred!
Three more hours later: Went for lunch, came back, hit the browser Refresh button, and the web site is up again. I am convinced that someone is fooling around with the settings at the back end.
Add a <clear/> element as the first element under the connectionstrings element to ensure no strings are being inherited. Also, I assume your Azure SQL DB is set up with proper firewall settings allowing your IP where the ASP.net code is deployed?
I also had this error. But in my case I did not notice that the connection string was being overwritten by the publish wizard. I fixed the problem by going to the Settings tab in the Publish wizard and unchecking "Use this connection string at runtime (update destination web.config)"
I have set up a remote server running SQl Server Web edition and full IIS 7.5. I am able to deploy my MVC 4 application to the remote box without issue, but when I try to run the website I receive the following error:
Login failed for user 'IIS APPPOOL\backoffice.mysite.com'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\backoffice.mysite.com'.
The Error Console says:
Exception information:
Exception type: InvalidOperationException
Exception message: The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588
at MyModels.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\Users\Administrator\Documents\MySite\MyModels\Filters\InitializeSimpleMembershipAttribute.cs:line 47
An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.
It is very possible that my connection string is incorrect as the error log suggests. My connection running locally in Visual Studio is:
<add name="MyDB" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=MyDB;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MyDB.mdf" providerName="System.Data.SqlClient" />
I have set up a transformation for the connection on the remote server as:
<add name="MyDB" connectionString="Data Source=(local);Initial Catalog=MyDb;Integrated Security=True" providerName="System.Data.SqlClient" />
Normally I use SQL login so I am confused here. What should the connection string look for SQL Server Web Edition using Windows Authentication?
It looks like the IIS APPPOOL\backoffice.mysite.com is the trying to create the DB. Is this correct? If so do I not need to create a login and user for this user in SQL Management Studio?
Do I need to create the DB in SQL Management Studio before running the deployment?
Thank so much!
you are running using Windows Authentintication for SQL Server. The IIS App is running under the user context of 'IIS APPPOOL\backoffice.mysite.com'; I would strongly suggest using either standard sql server credentials or creating a new user for that particular website that has sql credentials, probably better with regular credentials though. Integrated Security=SSPI in the connection string means Windows Authentication. So just use standard SQL Server credentials and set your database to mixed mode auth and set the User ID and Password in your connection string and then you will be up and running no problem.