-1

i am beginner is programming. I want to write a program by c# in visual studio 2015 with a simple database that takes some data, save it and read from that database. I wrote some of my code in a windows form application and now I want to add a database. I right-click on on my project name in the solution explorer and then choose "Add" and the "New Item". In the the opened window i click on "Service-Based Database", enter name and click on Add button. But at this moment it show me an error that u can see below:

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 names is correct and that SQL Server is configured to allow remote connections. (Provide: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

I did this before it and there was no error, but now I see to this error and I don't know what's the problem. I have installed SQL server 2015 on my windows 10 and when I enter "sqllocaldb.exe i" in the cmd, it shows me:

dbname MSSQLLocalDB

how can i solve this problem and add new database to my applications?

I have installed sql server on my computer and repair it once but when i wanted to check it from windows services i couldn't find sql server in the servisec.

thank you for your attention

Persian LionKing
  • 304
  • 1
  • 5
  • 19

1 Answers1

0

Go to your SQL Configuration Manager, then on left panel click on Sql Server Services (highlighted), might be that your SQL Server Default Instance (MSSQLServer) or whatever instance name you gave it, it's state might not be running. so start it up. Then try it again.

alomegah
  • 117
  • 1
  • 1
  • 7
  • I opened SQL Server Configuration Manager and when I click on SQL Sever Services in the left panel, It shows nothing on the mail(right) panel. just a note that "There is no items to show in this view" – Persian LionKing Jun 14 '17 at 17:42
  • 1
    First, have you tried running your SQL Management Studio, with Server name as your local Computer or using localhost as server name , and authentication as windows authentication – alomegah Jun 14 '17 at 17:46
  • Yes, I opened Management Studio, I right-clicked on the (localDB)MSSQLLocalDB... in the left panel and connected it again with windows authentication. the state and connection state of it is "Open" now and i think it was open before too. After that, I tried again to add new database to my visual studio project and that error showed again. – Persian LionKing Jun 14 '17 at 17:51
  • the problem still exists – Persian LionKing Jun 14 '17 at 18:00
  • have you installed your SQL server properly? your default SQL server instance should be displayed on SQL Server Services, on yours doesn't display any items, you need to modify/repair your sql server installation – alomegah Jun 14 '17 at 18:15
  • 1
    i was having this problem before, my first solution was to check the sql server instance if it was running on SQL Server Configuration Manger, this is important because you won't be able to connect to your SQL Instance it if it wasn't running, so this Instance should be displayed in SQL Services, i also encountered services not being displayed in SQL services, my solution to that was to modify/repair my sql installation.. i was a beginner like you too, sorry if i can't help you with my solution – alomegah Jun 14 '17 at 18:24
  • I went to SQL server Installation center and clicked on "Repair" from "Maintenance" Menu and It finished it's progress and still there is no item in the services in sql server configuration manager – Persian LionKing Jun 14 '17 at 18:52