SQL Server Express is not installed on your system - sql

When I try to open code for an existing ASP.NET MVC application in Visual Studio 2015, it shows a warning like
In that application, there is a connection string:
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />'
I have SQL Server 2012 installed in my system.

Pretty easy:
Attach that .mdf file that's being referenced in the original connection string to your SQL Server 2012 instance
Change the connection string to the new situation - something like:
<add name="ApplicationServices"
connectionString="data source=.;initial catalog=aspnetdb;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
Just simply ignore that VS warnings if it ever occurs again ....
The reason for the warning is the AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true setting of the original connection string; this approach (which I DO NOT recommend at all) only works with the Express edition of SQL Server - not with any other editions.

Related

Database shows up in App_Data & not in SQL Server

Does anyone know why my database won't show up in SQL Server, but will show up in App_Data? I did code first migration and update the database but still can't see it. Please help
I try changing the connection and it did not work
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Rentals.mdf;Initial Catalog=aspnet-Rentals;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
No database shows up

How to access a server system's local db from another system?(case:server-client scenario)

we used this connection string in client system where "Data Source=.*.**.57" is of server ip address and made the changes in the sql server configuration manager in server system accordingly.(i.e: TCP/IP protocol enabled)
<connectionStrings>
<add name="ConString"
connectionString="Data Source=**<ip address>,1433\SQLEXPRESS;Initial Catalog=HYD_TM;User ID=**;Password=**;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
Its always easier to debug connection string problems from an interface that is interactive such as Excel or sql management studio. In excel you can try to import a table from the data tab. If you succeed you can inspect the connection string and use it in your app.

Uploading Website with Visual Basic Inbuilt .mdf Database in VB.Net (Aspx)

I am creating a website to have a database with it (i.e. Upload the website with the App_Data folder that has Database.mdf in it).
But it cannot connect the attached database using (web.config file)
It works on localhost but it does not work when uploaded, can anyone help me?
**
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" />
</connectionStrings>
<appSettings>
<add key="ConnectionString" value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" />
</appSettings>
**
The attribute 'Data Source' in ConnectionString notifies SQL Server instance you are using. On Localhost, it will work fine because you have a actual SQL service running there. But when you upload the Site to web server, you must have a SQL server instance running there.
To achieve that, you have to upload your database to server, then you will get server username, password. Now change the connectionstring according to that in web.config and your application will work fine. No need to keep .mdf in App_Data folder.

ConnectionStrings error 26 - SQL / Visual Studio

I have added a database file (NORTHWND.MDF) to my application using Visual Studio 2010 built-in functionality. Database is in the App_Data folder.
It is running fine in local-host. But when I publish it and upload it to server it gives this error:
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)
My connection string is that automatically generated by visual studio in my web.config:
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
My host support SQL Express, but it dont work..
I read that once everything is upped on the host do not have to use "AttachDbFilename" .. but I have not figured out how to fix it .. Could someone tell me the correct connection string?
Thanks in advance.
You Sholud Use this connection String if you have your db attached to SQL management Studio
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\myUsername;Password=myPassword;
Reference:
https://www.connectionstrings.com/sql-server/

how to handle database reallocation for dotnetnuke website

i have a website that used to run on sqlexpress data base i changed my server and it stopped running i ran it using visual studi and IIS but it eith gives me error 404 or error 503 i think the problem is in my webconfig sql string connection her is my code:
<connectionStrings>
<add name="SiteSqlServer" connectionString="Data Source=localhost;Initial Catalog=ULTRA; User ID=admin;Password=123" providerName="System.Data.SqlClient" />
<add name="SiteSqlServer" connectionString="Server=(local);Database=DotNetNuke;uid=;pwd=;" providerName="System.Data.SqlClient" />
-->
<!-- Connection String for SQL Server 2008/2012 Express -->
<!--<add name="SiteSqlServer" connectionString="Data Source=localhost;Initial Catalog=ULTRA; User ID=admin;Password=123" providerName="System.Data.SqlClient" />-->
<!-- Connection String for SQL Server 2008/2012
-->
<!--<add name="SiteSqlServer" connectionString="Server=(local);Database=DotNetNuke;uid=;pwd=;" providerName="System.Data.SqlClient" />-->
</connectionStrings>
<appSettings>
<!-- Connection String for SQL Server 2008/2012 Express - kept for backwards compatability - legacy modules -->
<!--<add key="SiteSqlServer" value="Data Source=.\SQLExpress;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True" />-->
<!-- Connection String for SQL Server 2008/2012 - kept for backwards compatability - legacy modules
-->
<add key="SiteSqlServer" value="Server=(local);Database=DotNetNuke;uid=;pwd=;" />
would someone please help me to tell me what is wrong?
You have your connection string defined multiple times in the ConnectionStrings section of the web.config. Which is the proper connection string?
EDIT:
You likely have an issue with the PortalAliases and your IIS configuration. What is the URL that you are trying to access the website using? Make sure that URL is listed in the PortalAliases table, also make sure that IIS will respond to the URL as well.