There is a client in the form of an ASP.NET MVC application, there is a WCF service, requests to the WCF service are sent from the client, the service itself manipulates database data through the Entity Framework. Everything works locally in the Visual Studio development environment via IIS Express, but when I deploy this service on a Windows service, an error appears
"The underlying provider failed on Open."
DB connection string in app.config
<connectionStrings>
<add name="AddressBookEntities"
connectionString="metadata=res://*/ContactModel.csdl|res://*/ContactModel.ssdl|res://*/ContactModel.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\AddressBook.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
I suggest you use SQL Server Express, attached filename requires a particular user context
Related
After publishing my locat asp.net website to IIS server, it can not communicate with database. I'm checking if the api are working properly with Postman. And here is the error.
<connectionStrings>
<add name="HsptlMgmnt" connectionString="server=amso1; database=hoptialfinaldb;Trusted_Connection=false;uid=tanvir;password=1234;" providerName="System.Data.SqlClient" />
</connectionStrings>
I have an ASP .NET web api project that connects to MS SQL database using entity framework. The project works fine when ran locally.
I published the project on Azure, created a DB in cloud, also added the necessary tables in the DB. After the website is published, everything seems to be fine until I try to access the controller (Eg: mywebsite.azurewebsites.net/api/Groups), I get this error:
I have Enable Migration before publishing my project. When enabling migration, I got an error saying there are two DB: ApplicationDbContext, and myDB (which is where the tables are). So I enabled migration only on myDB. Does the error has anything to do with that?
EDIT:
Here is the connection string from Azure and web.config file:
Web.Config file:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=tcp:xxxxxxxxx.database.windows.net,1433;Initial Catalog=IMS;User Id=userName#xxxxxxxxx;Password=myPassword" providerName="System.Data.SqlClient" />
<add name="IMSEntities" connectionString="metadata=res://*/Models.IMSEntities.csdl|res://*/Models.IMSEntities.ssdl|res://*/Models.IMSEntities.msl;provider=System.Data.SqlClient;provider connection string="Data Source=tcp:xxxxxxxxx.database.windows.net,1433;Initial Catalog=IMS;User Id=userName#xxxxxxxxx;Password=myPassword"" providerName="System.Data.EntityClient" />
<add name="IMSEntities_DatabasePublish" connectionString="Data Source=tcp:xxxxxxxxx.database.windows.net,1433;Initial Catalog=IMS;User ID=userName#xxxxxxxxx;Password=myPassword" providerName="System.Data.SqlClient" />
</connectionStrings>
From Azure (All Settings >> Application Settings >> Connection Strings). The name of the connection string in Azure is DbConnectionString
Server=tcp:xxxxxxxxx.database.windows.net,1433;Initial Catalog=IMS;Persist Security Info=False;User ID=userName#xxxxxxxxx;Password=myPassword;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Thank you for your help!!
I am trying to setup DNN on my local machine but having following error.
Installing DotNetNuke
Upgrade Error: ERROR: Could not connect to database specified in connectionString for SqlDataProvider
I have a SQL Server 2014 Express installed with custom login created.
I can login and access to database with same credentials using SQL Management Studio.
In web.config file, I have following lines for Database connection:
<connectionStrings>
<add name="SiteSqlServer" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=<dbName>;User ID=<UID>;Password=<PWD>" providerName="System.Data.SqlClient" />
<add name="SiteSqlServerAcuity" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=<dbName>;User ID=<UID>;Password=<PWD>" providerName="System.Data.SqlClient" />
<add name="AcuityEntities" connectionString="metadata=res://*/DAO.Model.SalesAcuity.csdl|res://*/DAO.Model.SalesAcuity.ssdl|res://*/DAO.Model.SalesAcuity.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;Initial Catalog=<dbName>;Persist Security Info=True;User ID=<UID>;Password=<PWD>;MultipleActiveResultSets=True;Application Name=EntityFramework"" providerName="System.Data.EntityClient" />
and
<appSettings>
<add key="SiteSqlServer" value="Data Source=.\SQLEXPRESS;Initial Catalog=<dbName>;User ID=<UID>;Password=<PWD>"></add>
</appSettings>
I verified and changed connectionstrings in both sections as per so many references on internet but none of them worked.
Is there any other configuration needed? Or any change needed in web.config or Database configuration ?
THIS IS NOT A DFAULT DOTNETNUKE PACKAGE. ITS A CUSTOM PROJECT I AM TRYING TO SETUP.
There are a few things to consider, depending on the nature of the setup that you have.
Ensure that the Web Server can connect to the DB server. You may be able to connect to the server, but the web server itself cannot
Ensure that the user account being used has DBO rights, if DNN needs to upgrade etc it needs that level of permissions
This is more of a comment to #Mitchel Sellers answer, point 1. But it's a bit too much for a comment field.
Run the SQL Server Configuration Manager.
Go to "SQL Server Network Configuration".
Click "Protocols for <INSTANCE>".
In the right pane double click on "TCP/IP".
Make sure that "Enabled" is set to "Yes".
Go to the tab "IP Adresses".
For each IP, set the "TCP Port" to "1433", the "TCP Dynamic Port" to
"0" and "Active" and "Enabled" to "Yes".
With "IPALL" just set the port to "1433", leave the Dynamic as is.
Reboot or restart the SQL Server service.
With these steps I get a connection to the database from IIS using localhost
If you cannot find the Configuration Manager in the Start Menu, you can run it manually with C:\Windows\SysWOW64\mmc.exe /32 c:\Windows\SysWOW64\SQLServerManager12.msc
I have an ASP.NET MVC 5 website that connects to a remote sql database.
The website works fine when it's running from the visual studio iis express.
However, when i deploy the website on azurewebsites and attach the debugger on the login function, i see that the UserManager.FindAsync function redirects me to the general error view page.
This is where the UserManager checks if user exists:
var user = await UserManager.FindAsync(model.UserName, model.Password);
And this is the web.config connection string:
<add name="DefaultConnection" connectionString="Data Source=87.87.87.87,1433;Initial Catalog=dbname;Integrated Security=False; User Id=username; password=password" providerName="System.Data.SqlClient" />
This website works when it's deployed elsewhere as well.
The problem occurs when it's deployed on azurewebsites.
My problem is the following: I want to connect to a SQL Server Express instance on a local network with my C# application; the IP is 192.168.1.147 and the SQL Server port is 1433.
I have a code-first database running smoothly, I can connect from the PC that is hosting the service but not from another computer.
How can I set my connection string, or where should I do it? What would be the correct format? And how should I use it in my application?
I tried the following:
192.168.1.147\SQLEXPRESS,1433
192.168.1.147:1433\SQLEXPRESS
192.168.1.147,1433
EDIT: the connection looks like this in my app.config:
<connectionStrings>
<add name="Amnesia.Client.Properties.Settings.AMNContext"
connectionString="Data Source=192.168.1.147\SQLEXPRESS,1477;Initial Catalog=Amnesia.Server.Repository.AmnesiaContext;Persist Security Info=True;User ID=whatever;Password=whatever"
providerName="System.Data.SqlClient" />
</connectionStrings>