I developed an application in C# using visual studio 2015. But when I published the application and run it on another system. It gives the following exceptions.
" A network related or instance specific error occurred while establishing a connection to SQL server. The server was not found or was not accessbile. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. Unable to locate a local database runtime installation.
While publishing database, we need to cleanup the dev configurations a little further.
In the connection string check what is the Database server name on your client hosting environment and include that in: Data Source="Client database host server name"
Also instead of providing .mdf file ( as specified in your connection string with AttachDbFilename='C:\Users...'), better would be either generate the script from SQL Management studio in your local and run those in your client environment.
If it is by requirement to provide .mdf file then make sure the path to mdf file in hosting environment matches to what you give in your connection string.
Or else you can provide mdf file to client ask them to attach it to the hosted database server.
Often, Integrated Security might not be provided on host servers. So check the userid/password with your client on hosting machine to connect and update them in your connection string.
Hope some of these point might help you.
Related
I was creating a web site project in Visual Studio 2015, created an App_Data folder and tried to add a SQL Server database file.
This error occurred:
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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
I am using Microsoft SQL Server 2014 (v12.0). I checked the connection in SQL Server Configuration Manager, the server connection is enabled, my TCP/IP port is set to 1443, my Firewall is set for the connection as well.
I am able to connect to my server from Visual Studio Tools/Connect to Database Option, it's able to connect either to my server or to a local database. When I test my connection from there, it works.
I also see the connection is enabled and running from server explorer, and when I drag and drop an SQL DataSource Wizard from my ToolBox to an aspx page, the wizard sees the database and is ready to import it as well.
I also have tried double checking the connection under services.msc from cmd and it's all up and running.
Yet, when I want to right click and add a SQL Server database file to my App_Data folder, this error comes up.
I have no idea what is wrong.
Try to use (localdb)\mssqllocaldb as server name to connect to the LocalDB automatic instance. for more information read this article: http://www.sqlcoffee.com/SQLServer2014_0010.htm
Just for documentation (and SQL Express users having the same problems)
1. Check that SQL Express (master-) database exists and is reachable
In Server Explorer => Data Connections => Add Connection
(LocalDb)\mssqllocaldb
(LocalDb)\v12.0
(LocalDb)\v11.0
For further SQL Express problems see:
SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance
2. Configure Default Connection in Visual Studio
If you upgraded SQL Express the wrong connection string still resides in the VS configuration
Tools => Options => Databas Tools => Data Connections -> "(LocalDB)\mssqllocaldb"
My objective was to make a database for general store. Information was very scattered about how to create database and why in that way. So i selected SQL Server Express.
Application was made in C# Visual Stduio 2012. Database was created with SQL management Studio. To connect the application with database i used serverexplorer in visual studio and assigned ./sqlexpress
Now the problem is that database works fine on my pc but when i deploy application on the clients pc it says
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)
Connection String Used connectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=pos;Integrated Security=True";
Where i went wrong ? Is database also deployed with published app or i have to do some other steps ? Will i have to install SQL server on client pc too?
Note: The application is local. i don't need to transfer data via internet.
Let me know according to your experince what is the right way to attach,create and deploy database the right way for this small project because internet is full of guide but there is no where mentioned properly why the specific method is adopted etc
I solved the issue by download sql server management studio on client pc. I just made a backup of database form my management studio and restored that backup file from clients management studio. And now everything is working
I have developed an inventory system in C# ,database used is SQL server .Now my problem is how to deploy my project with database and run it on client's machine i have 1 more week remaining in delivering this project .I tried many blogs and sites but all in vain and i did not get any good resource which clearify me all this scenerio.The current publishing process does not have a database file and showing me an 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
Please any suggestions would be highly appreciable?
I am using Visual Studio 2013 and SQL Server 2012!
By default, SQL Server have network access disabled after a fresh install. You need to use the SQL Configuration Manager to allow remote connections to the instance.
See this post:
http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
http://www.romankagan.com/?p=118
If after this you still can't connect, verify that SQL Server ports are not been blocked by the machine firewall.
I am trying to learn C# and then I hit this roadblock. My Visual Studio 2010 wont let me create a service based database (the .mdf file). (Add>New Item>Service-Based Database)
Everytime I try to add new .mdf it would bring up an error.
A network-related or instance-specific error occurred while
establishing a connection to the 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 can create a Local Database (Add>New Item>Local Database) without any problem, but I cant create .mdf
I am running on Windows 7 64bit OS and Visual Studio 2010 (Ultimate).
A service-based database needs to connect to a SQL Server instance. It's not built into Visual Studio, it's a separate application which needs to be running somewhere for you to connect to. That error message is basically telling you it can't find the SQL Server instance you're trying to connect to.
Local Database works correctly because it keeps everything local to your application and doesn't require an external database server to function.
Basic requirements for using these two kinds of databases:
Local Database (.sdf): requires SQL Server Compact. That is, you need only an additional DLL, but no special system service. (If you know SQLite: SQL Server Compact is conceptually the same thing, only more powerful and feature-complete.)
Service-Based Database (.mdf & .ldf log/journal file): requires a running instance of SQL Server or SQL Server Express, both of which are standalone products (as Tim Copenhaver points out in his answer). For development purposes, you'd typically install one of these products on your development machine.
Likely cause of your problem: Guessing from the error message that you posted, you do not have SQL Server, nor SQL Server Express, installed. However, an instance of one of these products is required so that you can "attach" your database to it. This is required in order before you can actually access the .mdf database.
To see whether you have SQL Server installed, you could e.g. open Control Panel → Administrative Tools → Services, and look out for a system service named "SQL Server (.\SQLEXPRESS)", or "SQL Server (YOURCOMPUTERNAME\MSSQLSERVER)", or similar. The name in the brackets is the name of the database instance running on your machine. SQLEXPRESS is the default instance name for SQL Server Express, while MSSQLSERVER is the default instance name for the full version of SQL Server.
If you do not have SQL Server installed, you can download e.g. SQL Server 2012 Express or SQL Server 2008 R2 Express with SP2 for free from Microsoft.
You can try
Go to Command Prompt from Start->Run(type cmd -> press enter)
Check SqlLocalDB by
Sqllocaldb.exe i
You will see version number like (v11.0) otherwise complete the
installation.
Create the sqldb by
sqllocaldb c dbname
You will see like "LocalDB instance "dbname" created with version 11.0."
Then Start the Db
sqllocaldb s dbname
You will see like "LocalDB instance "dbname" started"
See the created Db info
sqllocaldb.exe i dbname
Now try to create service-based database in c#.
To temporarily attach a database file (.mdf) from the Data Connections node
In Server Explorer, open the short cut menu for Data Connections and choose Add Connection.
The Add Connection dialogue box appears.
Choose the Change button.
The Change Data Source dialogue box appears.
Select Microsoft SQL Server Database File and choose the OK button.
The Add Connection dialogue box reappears, with Microsoft SQL Server Database File (SqlClient) shown in the Data source text box.
Choose the Browse button and browse to an existing .mdf file.
If you type a file name that does not exist, a blank .mdf file will be created.
Select either Use Windows Authentication or Use SQL Server Authentication.
For more information on SQL Server database access authentication, see Create New SQL Server Database Dialogue Box.
Choose the OK button.
The database appears in Server Explorer.
I was making minor modifications to a view in my ASP.NET MVC 3 C# application when all of a sudden the application would no longer run. The error message is as follows:
System.Data.SqlClient.SqlException: 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: Shared Memory Provider, error: 40 - Could not open a connection to SQL Server)
Upon close inspection of the server explorer I noticed that all database connections are no longer working. I cannot expand any of the connections to view the tables and data I previously generated within. When I attempt to, there is a pop-up window that is generated that repeats the exact same error as above.
It is important to note that I was not making any modifications to any portion of the application that pertains to a database. I was rearranging some of the visual components of a view in my application when all of this occurred. I had just recently restarted my computer and had made no other modifications since that time.
At first I thought that somehow SQL Express had overwritten my development environments version of SQL Server and began to reinstall SQL Server Express. The installation fails every time now. There is no specific error. Windows generates an error message saying that the setup application "stopped working" and hangs until closed.
I have tried several different versions of the SQL Server Express installation package, and they all result in the same error happening at different points in the installation process. To be clear, I'm not even sure SQL Server Express is the problem. I don't know why it would be since I'm using the SQL Server edition that is built into Visual Studio 2010.
Is the SQL service running? Check under SQL Server Configuration Manager.
Yes, another life saved.
Run-sqlservermanager11.msc, right click and start.
Is the SQL service running? Check under the SQL Server Configuration Manager.
I assume you've already tried to repair install, to uninstall and to restart your computer, pray then try again?
Are you databases remotely deployed? Because it is possible that the network is down.
Secondly, check in the we.config file if you have specified the correct credentials. Try to log in through SQL Server Management Studio.
One more thing: Stop the SQL Server service, and start it again. Or you can reboot the system.