I have developed a web site that utilizes login in control using the ASP.NET Web Site Administration Tool. I then moved the entire project over to the server that will be hosting the project. I have the site on IIS 7 but when I try to login, I get 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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
)
I have given the proper permissions to NETWORKSERVICE. It seems from browsing around online that this is a sql server problem. It works fine in VWD Express but not on IIS. I know that the roles,users,permissions are stored in a .mdf but I'm guessing that it's not being accessed correctly.
Does anyone have any insight on this?
Here is my connection string:
add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-GMPL-20130618083445;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-GMPL-20130618083445.mdf"
providerName="System.Data.SqlClient"
Thank you in advance!
It's trying to use "LocalDB", which is probably not installed on your server. You probably should be connecting to a regular database, as opposed to LocalDB.
LocalDB is a new kind of SQL Express - seems to be made for development machines rather than for actual servers.
change Connection string to
"Data Source=.\SQLEXPRESS;Initial Catalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True"
Related
I developed an ASP.NET web application and it worked fine locally with IIS express.
I created deployment package and installed the application on my Windows 2012 server.
When developing the application, I was using an mdf file with localdb v11.0. On the server, however, I wanted to use sqlserver express. I changed the connection string to
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\nameoffile.mdf;Integrated Security=True;Connect Timeout=30
After making this change I was able to connect to the application from another host on the network. Viewing data and using filters/search (built into stored procedures) works fine.
The error occurs when I try to insert new records or delete records. The message is:
Server Error in '/Nameofapplication' Application.
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've turned off the firewall, allowed remote connections, started sql server browser and agent and various other solutions that I've found from googling without any luck.
Any ideas about how to solve this issue?
EDIT: One important detail that I original left out (because I didn't know it was important) is that we were running these sites in full IIS, not from IIS Express.
We're trying to setup local dev environments for Kentico CMS that will add our local machines to our current synchronization chain of Dev --> Staging --> Prod (so we'll wind up with Locals --> Dev --> Staging --> Prod).
We copied our Dev DB to our local machines onto the (localdb)\v11.0 instance of SQL Server, but we're running into an issue on everyone's computers except mine.
Here's the error we're getting:
The application could not connect to the database, please check the
connection string in the web.config file and SQL server availability.
Original 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: 50 - Local Database Runtime error occurred.
The specified LocalDB instance does not exist. )
I've tried a ton of suggestions from other SO answers and other websites to figure out why we're getting this error (and why it's not happening on my machine), but no luck. We can connect to (localdb)\v11.0 in SSMS but we cannot connect to it through VS (same error). Also, when we open Sql Server Config Manager, we're not seeing any listings for SQL Server Services. Any ideas?
Make sure you have .NET Framework 4.0.2+ installed
Set up your AppPool to run under the NetworkService account.
Create a login for that account in your db.
USE [master];
CREATE LOGIN [NT AUTHORITY\NETWORK SERVICE] FROM WINDOWS;
EXEC sp_addsrvrolemember N'NT AUTHORITY\NETWORK SERVICE', SYSADMIN;
Share your instance with all users by running
SqlLocalDB share Kentico KenticoShared
Use connection string in the following format:
<add name="CMSConnectionString" connectionString="Data Source=(localdb)\.\KenticoShared;Initial Catalog=KenticoDB;Integrated Security=True;Connect Timeout=60" />
If it doesn't help use a named pipe:
<add key="CMSConnectionString" value="Persist Security Info=False;Integrated Security=SSPI;database=KenticoDB;server=np:\\.\pipe\LOCALDB#D2BA6590\tsql\query;Current Language=English;Connection Timeout=120;" />
Notes:
the exact name of the NetworkService account on your machine can be determined by running following C#
var ns = new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null).Translate(typeof(NTAccount)).ToString()
named pipe can be determined by running this in CMD: SqlLocalDB info KenticoShared
don't forget to run your instance SqlLocalDB start KenticoShared
Seems a little obscure, but have you looked at http://support.microsoft.com/kb/941823 , "Some or all SQL Server 2005 services are not listed in SQL Server Configuration Manager..."?
And there are generally two things that get in the way of connecting to SQL Server from an application even though you can connect using Management Studio. First, you should make sure that TCP is enabled on the instance, http://msdn.microsoft.com/en-us/library/bb909712(v=vs.90).aspx . Second, since you're connecting to a named instance, which I'm assuming is not the default instance running on the standard port, you need to make sure that the SQL Server Browser service is running, http://technet.microsoft.com/en-us/library/ms165734(v=sql.90).aspx . This is what redirects applications to a non standard port without having to specify the port directly. The reason Management Studio can get past these is that it can connect through named pipes and skip TCP altogether.
See this post as this solved my problem:
These two posts on Using LocalDB with Full IIS should give you more information. Especially the second part seems relevant, but the first one contains some context as well.
Part 1: User Profile
Part 2: Instance Ownership
Credit: IIS connecting to LocalDB
Hi i want to publish my application in a IIS server.
First i create a database in my sql server and put all my needed data on it.
Then i update my web.config to use the new remote Database. Unfortunatly i get an error
ConnectionString:
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=IntranetDatabase;Data Source=SRVDEV2010\SRVDEV2010" />
Stacktrace :
[SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
I cheked if i can access database remotly. I create a udlfile to verify my connectionstring, Here is the result.
I don't know why the udl file can connect but not my application. Any help is appreciated
Under which user is the Application Pool configured to run? you're using Windows Authentication which means your IIS App pool should be configured to run under a user that has access to the DB.
I have a web app that I developed using Visual Web Developer 2010. The database is local inside the solution:
<add name="SFDBConnectionString"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SFDB.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
I'm trying to run the app on another machine using Visual Studio 2010 instead of the web developer and it's giving me the following error when it tries to connect to the database:
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)
Does anybody has any idea on what could be happening?
Usually, this error message means exactly what it says...
Can you connect to the SQL server through UI client (like, management studio)? If yes - how do you do that (user/password or Windows authentication; what is the server name)?
What is the connection string? You put here the connection string to SQL Express (which works; so it isn't quite helpful) - but forgot to put the connection string that doesn't work.
If you can connect in UI, and connection string is correct - there is no reason why the code would throw 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. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
when i upload my site on webserver and connect with remote sqlserver2005 using connection string....
<connectionStrings>
<remove name="ConnectionString"/>
<add name="ConnectionString" connectionString="Data Source=69.16.253.19,1433;Initial Catalog=vb_usa;Persist Security Info=True;User ID=username;Password=password" providerName="System.Data.SqlClient"/>
</connectionStrings>
it produces the following errr --
you can see error in my webpage :
http://vbi.volvobusesindia.com
it shows an error above ..
i m using aspnetdb.mdf in my website in APP_Data Folder... features i use in my website is Login Control, Password recovery, signup control...
Tried all the above but did not work for me. When I checked Services, I found that the SQLExpress service which was set Automatic, was not started. Once I started the SQLExpress service, everything worked.
See the guide in this site http://www.connectionstrings.com/sql-server-2005
In particular look at the section on that page titled "Attach a database file, located in the data directory, on connect to a local SQL Server Express instance"
The format is:
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;
Database=dbname;Trusted_Connection=Yes;
Basically, you need to connect to the SQL Express instance installed on the web server and point it to where your database file is located.
On that remote machine (63.15.223.19), the SQL services are not running. You can go to that machine and try to run "net start mssqlserver" from command prompt.