Installing DotNetNuke : Database Connection Failing - c#

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

Related

Get SQL Connection error while using Web Service with local SQL Server database

I'm setting up a web service, I wanted to use the local database so I created a local SQL Server database in this project. The web service runs just fine on localhost, but the problem when I invoke a method to Load data from the local database on this project, I'm getting an error:
System.Data.SqlClient.SqlException:
An attempt to attach an auto-named database for file C:\Program Files (x86)\IIS Express\TourTravelDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
TourTravelDB.mdf is my local database
I've added a connection string in my web.config but it's still not working.
Here is my connection string.
<connectionStrings>
<add name="CS"
connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\TourTravelDB.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
I've also tried to move my database to the IIS Express directory, it works but when run it from another computer, I have to move the database again.
Does anyone have an idea how to solve this?
This may help you..
Add "User Instance=True;" in your connection string.
<connectionStrings>
<add name="aspnet_staterKits_Test_TimeTracker"
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"/>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf;"/>
</connectionStrings>
if doesn't work then try out the below links..
forums.asp.net
codeproject.com
Already existing thread in stack overflow

How i can change connection string after publishing the project?

When i change connection string after publish project in visual studio it is giving me an error
Here is my app.config file
<connectionStrings>
<add name="DataContext" connectionString="metadata=res://*
/Model.DataContext.csdl|res://*/Model.DataContext.ssdl|res:
//*/Model.DataContext.msl;provider=System.Data.SqlClient;provider connection string="data source=CODE-SERVER\SQLSILENT;initial catalog=pos-standard;persist security info=True;user id=sa;password=abc123**;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
and in new app.config file i want to replace this connection string it my local database connection string.
<add name="DataContext" connectionString="metadata=res://*/Model.DataContext.csdl|res://*/Model.DataContext.ssdl|res://*/Model.DataContext.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=pos-standard;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
I also attach here a error window
Are you sure that your database authorises Integrated security ?
Can you connect using SQL server management studio with integrated security ?
If yes, try to not replace all the connection string but only remove username and password ant put integrated security = true, and change server name.
Finally, check the database server name may be .\Something.
You need to re-sign the application and deployment manifests after you have edited the config file. Please refer to the following links for more information about this.
http://msdn.microsoft.com/en-us/library/dd465299.aspx
Resign Clickonce manifest using mage.exe

Login failed while connecting to database

I have created WPF application which has MDF file. When I added MDF file to my solutions folder It automatically created a connection string for me
<add name="Connection"
connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=C:\Users\Public\Desktop\MyDatabase.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
I Deployed my application using SQL Server Compact (as described here). But When I run my Application I am getting exception
Cannot open database "C:\Users\Public\Desktop\MyDatabase.mdf" requested by the login. The login failed.
Login failed for user 'MY-PC\NAME'.
I am using Windows Authentication for my SQL Server
change your connection string as follows:
<add name="Connection"
connectionString="Data Source=(LocalDB)\v11.0;Initial Catalog=C:\Users\Public\Desktop\MyDatabase.mdf;persist security info=True;Integrated Security=SSPI;"providerName="System.Data.SqlClient" />

How to set and use connection string in C# entity framework

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>

Establishing connection of SQL Server 2008 with VS2012 project via web.config file

I'm trying to connect my database from my SQL Server to my asp.net project through the web.config file. I found code like this which should be able to connect my SQL Server and ASP.net project together properly. However after adding this code, I got this error.
This is my SQL Server connection string that is supposed to be place in web.config:
<connectionStrings>
<add name="MyConnectionString"
connectionString="Data Source=sergio-desktop\sqlexpress;Initial
Catalog=MyDatabase;User ID=userName;Password=password"
providerName="System.Data.SqlClient" />
</connectionStrings>
And this is the error
I'm also not very sure if the syntax of my connection string to establish connection between the two is correct.
As the error suggests, the connection element should not go in system.web section. it should go in configuration section of your web.config
as
<configuration>
<connectionStrings>
---

Categories

Resources