0

I'm using Visual Studio 2015 and SQL Server Management Studio.

I can connect to the database server in SQL Server Management Studio but when I try to create a SQL Server database file in my web project in Visual Studio, 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: 50. Local Database Runtime error occurred. The specified LocalDB instance does not exist.

I tried the following and still get the same error

  1. Checked the SQL Server service is up and running
  2. Made sure database engine is configured to accept remote connections
  3. Created an exception on the firewall for the SQL Server instance
  4. Enabled TCP/IP in SQL Server Configuration and set TCP Port to 1433
  5. Enabled SQL Server Browser Service

I spent all my day on this and I really hope I get any help or hint to put me in the right direction.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
twobits
  • 71
  • 1
  • 8
  • Did you enable the TCP/IP native client in SQL Server Configuration Manager? – joelc May 22 '17 at 17:30
  • Did you see [this](https://stackoverflow.com/questions/26248293/sql-network-interfaces-error-50-local-database-runtime-error-occurred-canno)? Might be helpful. – fqhv May 22 '17 at 17:42
  • @joelc yes it is enabled – twobits May 22 '17 at 17:55
  • When you attempt to create the DB in VS, are you using hostname or IP address to identify the server? Also, can you telnet to port 1433 on the machine from your workstation or does it say connection refused? – joelc May 22 '17 at 18:00
  • Your connection string is of the form `(localdb)\foo`, where `foo` is a LocalDB instance that does not exist. If it is your intent to use LocalDB, use `sqllocaldb create foo` on the server to create it. If it is not your intent to use LocalDB, change your connection string. – Jeroen Mostert May 22 '17 at 18:02
  • Are you trying to connect default instance or named instance? – Kannan Kandasamy May 22 '17 at 18:04
  • SQL Server Express **LocalDB** doesn't accept remote connections – sepupic May 22 '17 at 18:18
  • @joelc I'm not sure how i'm identifying the server, I right click on my project > Add > New item > SQL Server Database and write the name of the database to be created – twobits May 22 '17 at 18:59
  • @KannanKandasamy to the default instance. But I noticed it's named hostname in Server explorer in VS and hostname\sqlexpress in SQL Server Management Studio – twobits May 22 '17 at 19:04
  • Hmmm, maybe it's using a named pipe if it's hitting the local machine? I don't know for sure. Perhaps enable the rest of the protocols and clients and see if that works? Also try using a telnet client to connect to port 1433 locally from your command prompt and see if that works. – joelc May 22 '17 at 21:28

0 Answers0