I have a Windows Form project in VS2015 that uses a local database file (.MDF).
The code has been working for some time, but recently I was having a problem restoring from a backup file. I decided to uninstall SQL Server (different versions) and do a fresh install of SQL Server Express 2016 SP2 (Advanced version).
The install went okay and I did include LocalDB which is needed to connect local .MDF database files. Under 'Programs and Features' I can see several Microsoft SQL Server 2016 items, including LocalDB.
Now, for some reason I cannot connect to the local database. In VS, in Server Explorer, I try to add the .MDF file to 'Data Connections'. In the 'Add Connection' dialog I select 'Microsoft SQL Server Database File' as the source. Then I browse to and select the .MDF file. I use Windows Authentication (which I choose during SQL Server install). Clicking on 'Test Connection' produces 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: 0-
I believe the problem is something with SQL Server installation because the installed version of my project also cannot connect to the database. Could it be a Windows Registry issue?
Would very much appreciate help.
What I have tried:
I did a fresh install of SQL Server Express 2016 SP2 (Advanced version).
I verified 'LocalDB' was included in the installation.
Tried to connect to a known working .MDF database file in Visual Studio 2015,
but always get the error message.