I'm using Windows 11 and I have a SQL Server LocalDB database that is accessed by a desktop application and Power BI desktop. It used to work normally but suddenly I started seeing connection issues, as described below. The SQL server has a named instance accessed using SQL Server authentication.
Sequence:
Restart the machine, check the instance from the command prompt
C:\Users\xxx>sqllocaldb info "Instance"
Name: Instance
Version: 11.0.3000.0
Shared name:
Owner: Domain\UserName
Auto-create: No
State: Stopped
Last start time: 1/16/2023 10:04:30 AM
Instance pipe name:
Open Power BI Desktop, click Add data and try to add anything in the database, all is good and the connection is fine.
Check the instance state from the command prompt: same as above (so I can query the database from Power BI, while the instance state is 'Stopped')! How?.
Open the desktop application, the application cannot connect to the database and throws an exception at the Connection.Open method with this 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. Error occurred during LocalDB instance startup: SQL Server process failed to start.
And the following message is repeated in the Windows Application event log:
Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
Reported at line: 3621.
Try to start the instance from the command prompt:
sqllocaldb start "Instance"
Start of LocalDB instance "Instance" failed because of the following error:
Error occurred during LocalDB instance startup: SQL Server process failed to start.
Restart the machine again. Checking the state of the instance in the command prompt gives the same result as above.
Start the application, it starts normally, no connection errors.
Check the Instance state:
Name: Instance
Version: 11.0.3000.0
Shared name:
Owner: Domain\UserName
Auto-create: No
State: Running
Last start time: 1/17/2023 3:18:49 PM
Instance pipe name: np:\\.\pipe\LOCALDB#28451FA3\tsql\query
Start Power BI and try to connect to the database, it won’t connect. The following error appears
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. Error occurred during LocalDB instance startup: SQL Server process failed to start.
And this message comes up in the event viewer
Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
Reported at line: 3621.
I've searching in Google and Microsoft for a couple of days, but I cannot find anyone having the same issue. I suspect a recent update to Windows 11 that caused these issues, as it was running perfectly before.
Both the desktop application and Power BI should be able to access the database simultaneously without issues.
Related
I'm currently following this tutorial for ASP.Net Core: https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-3.1&tabs=visual-studio
I'm having an issue: when I get to the 2nd part of the tutorial where I add a model there's a step where I enter the following commands:
Add-Migration InitialCreate
Update-Database
Whenever I enter Update-Database I get the following 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: 56 - Unable to load the SQLUserInstance.dll from the location specified in the registry. Verify that the Local Database Runtime feature of SQL Server Express is properly installed.)
In the tutorial it never asks you to download or connect to a SQL Server so why do I get this error?
Error is saying that you cannot connect to sql server. Unfortunately, instructions are in Part 4 in tutorial. I suggest you to follow it.
https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/sql?view=aspnetcore-3.1&tabs=visual-studio
You have to obviously connect to the SQL server. if you don't this. how you expect will work Add-Migration InitialCreateand Update-Database.I assume that you did this connection. Now follow the steps below.
Actually, this Error basically gets when the SQL Service is stopped.
Step 1 : Type "window" button + R ,This will open Run prompt.
Step 2: Type "services.msc" in Run prompt and hit the enter.
or go to this window you have to search the Services like this-
Step 3: Then Search for SQLSERVER(MSSQLSERVER) and Restart the service.if not restart then start the service.
Follow this step,hope it's resolve your issue.
We are using SQLLocalDB to connect to a local database. No network access is required - C# Client application is on the same machine as SQLLocalDB. Sometimes I get the following error (only seems to happen on some PCs):
Microsoft.SqlServer.Management.Common.ConnectionFailureException: Failed to connect to server (localdb)\myserverinstancename. ---> System.Data.SqlClient.SqlException: Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=27888; handshake=0; ---> System.ComponentModel.Win32Exception: The wait operation timed out
Oddly, it seems to happen if the PC is offline, and if connected to any sort of internet connection and retried, the issue goes away. However, in most cases the connection works fine even when there is no connection.
The closest I've found to my problem is this: Connection to SQL Server Works Sometimes
But that is discussing full SQL Server, rather than SQLLocalDB, and the solution uses "Sql Server Configuration Manager", which doens't work with SQLLocalDB.
My questions:
Does SQLLocalDb use IPv6/TCP for some reason, even when on the same PC?
Is there a way to change these settings for SQLLocalDB?
Or is there a different cause for this issue?
Edit: With help from some of the comments below I realised that the line that fails is when it calls a database creation script. The initial attempt at connection seems to work, but when I run my creation script it throws a "Failed to connect to server".
/// This line works
var server = new Server("(localdb)\myserverinstancename");
/// this line works 99% of the time, but sometimes "failed to connect to server"
server.ConnectionContext.ExecuteNonQuery(databaseCreationScript);
I recently upgraded to Windows Server 2012 from 2003. It was a big IIS jump from 6 to 8.5. I cannot seem to get a named SQL Server instance on an alternate port to work in my ASP.net 4.0 website.
The connection string I am using is:
<add name="MyConn"
connectionString="Server=192.168.12.5\stage,7839;Database=mydb;uid=myun;pwd=mypw;" />
When the website tries to load in the browser, I get the following error:
[HttpException (0x80004005): 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: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)]
We've checked firewall settings to no avail. Is the syntax correct in the above example? I've done numerous searches and found examples of people using
192.168.12.5:7839\stage
or
192.168.12.5\stage;port=7839;
but both of those give syntax errors.
I need some confirmation on the correct syntax for the web.config file. Any help is greatly appreciated, thanks!
Can you go to SQL Server > Configuration Tools > Configuration Manager and see if that instance is really named what you think it is?
You should see something like this:
The entries SQL Server (instacename) on the right hand side show you what instances you have - they should be in state running, and the instance name is in the brackets. If it's MSSQLSERVER, then it's an unnamed default instance - otherwise it's the instance name. Is your instance name correct, as expected - and running?
I have a problem with interbase database and sqldependency c#. I want to detect changes in database.
When I run code:
public Form1()
{
InitializeComponent();
DbConnection c = new TAdoDbxInterBaseConnection();
c.ConnectionString = #"Database=C:\MeronaSoft\MSDB.gdb;User=SYSDBA;Password=masterkey";
SqlDependency.Start(c.ConnectionString);
}
I get:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: 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.
Maybe it is not possible to us interbase with sqldependency?
check these things
Make sure your database engine is configured to accept remote connections(I you are using centralized database)
•Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
•Click on Surface Area Configuration for Services and Connections
•Select the instance that is having a problem > Database Engine > Remote Connections
•Enable local and remote connections
•Restart instance
Check the SQL Server service account
•If you are not using a domain account as a service account (for example if you are using NETWORK SERVICE), you may want to switch this first before proceeding
3.If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings in your ASweb P.NET application
•Usually the format needed to specify the database server is machinename\instancename
•Check your connection string as well
Check this link A network-related or instance-specific error
Other wise go Control Panel\All Control Panel Items\Administrative Tools\services and start SQL SERVER(SQLEXPRESS).
I took an old software made by someone else, which need to connect to a database with the .mdf extension.
But when I run the software, I have an error 26. I have obviously checked Google and it seems the the main problem is the firewall. But if I disable it the problem doesn't dissapear.
Here is the code for connect the database :
DataClasses1DataContext db = new DataClasses1DataContext(Environment.CurrentDirectory + "\\bddgestionvin.mdf");
I've noticed, when I try to connect the database with the datacontext class it fail too with the same error 26. (see attached screenshot below)
The string connection used by this class is :
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\bddgestionvin.mdf;Integrated Security=True;Connect `Timeout=30;User Instance=True`
I know I'm a little vague but I never did that kind of stuff (connect to a .mdf database) And the code is not mine, feel free the ask further explanation / code. Any help is welcome !
P.S The error message is
SqlException was unhandled 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)
(Sorry for the french software)
Hi I don't know you may see these steps. Make sure that these steps should pass.
The reason that we get this error message is the client stack could
not receive SSRP response UDP packet from SQL Browser. It's easy to
isolate the issue. Here are the steps:
1) Make sure your server name is correct, e.g., no typo on the name.
2) Make sure your instance name is correct and there is actually such
an instance on your target machine. [Update: Some application converts
\ to . If you are not sure about your application, please try both
Server\Instance and Server\Instance in your connection string]
3) Make sure the server machine is reachable, e.g, DNS can be resolve
correctly, you are able to ping the server (not always true).
4) Make sure SQL Browser service is running on the server.
5) If firewall is enabled on the server, you need to put
sqlbrowser.exe and/or UDP port 1434 into exception.
You can read more from here
You can also try PortQry and validate your firewall does not block SQL Browser UDP packet
A network-related or instance-specific error occurred while establishing a connection to SQL Server. Failed to establish a connection with SQL Server.
The server was not found or was not accessible.
May be server is stopped, you don't have permission to access the server, or the instance name is not correct .
Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
Please goto SSMS and try connecting the server. Verify the SQL Server is running and your account is configured to access the service.
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Thanks