Solved

Cannot Open .mdf Database in Windows Application

Posted on 2016-07-27
7
38 Views
Last Modified: 2016-08-08
I have a Windows application (Visual Studio 2013) with an .mdf database. If I am in the VS development environment, I can open the .mdf file without problems but when I run the application with F5, I get the attached error message. On the pc is also SQL Server 2016 Management Studio installed. As far as I can see from Google, the problem is that SQL Server does not permit remote access. Is this right? If yes, how do I do to allow remote access?

Thanks in advance!


Best regards
Kim Neesgaard
Denamrk
0
Comment
Question by:Kim Neesgaard
  • 4
  • 2
7 Comments
 
LVL 12

Expert Comment

by:funwithdotnet
ID: 41732149
A .mdf connection is almost always local. No remote access needed.

To answer your question, if you want to enable remote access for SQL Server, run the SQL Server Configuration Manager and configure & enable the desired protocol under SQL Server Network Configuration. The TCP/IP default port is 1433. Also check that the desired protocol is enabled under SQL Native Client [version #] Configuration.   The firewall on both ends of a connection will need to allow the specified port.

You might try building your application and running the .exe without debugging. It might offer a clue as to the issue.

Good luck!
0
 
LVL 6

Expert Comment

by:Manju
ID: 41733161
attached error message?
0
 

Author Comment

by:Kim Neesgaard
ID: 41733469
Error messages is now attached.
EE-SQL.png
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 12

Expert Comment

by:funwithdotnet
ID: 41733943
Error 26 is the common "can't find server" error.

You can look at this link to begin troubleshooting the issue.

You can also post your connection string (don't compromise security) so we can look for some obvious error. Also, if you show us how you are using the connection, it might help.
0
 

Author Comment

by:Kim Neesgaard
ID: 41734550
-> funwithdotnet:
Your remark 'A .mdf connection is almost always local. No remote access needed.' is according to my experience with the same application on my previous pc where I ran Visual Studio 2010 (and SQL Server 2008 Management Studio) - here there was no problems to connect.

I used two connectionstrings (I have renamed database and folders):

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=E:\2. Kims data - applikationsudvikling\WinApp\foldername1\foldername\db.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"

And this if I would connect to the .mdf in the same folder a the .exe:

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=E:\2. Kims data - applikationsudvikling\WinApp\foldername1\foldername2\db.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"
0
 

Accepted Solution

by:
Kim Neesgaard earned 0 total points
ID: 41740387
The solution to this is pretty simple: for some reason an SQL Server was not installed together with the Visual Studio 2013 installation (which I think was the case for earlier versions of VS). Installation of SQL Server 2016 Express completely solved the problem.
0
 

Author Closing Comment

by:Kim Neesgaard
ID: 41746977
It solved the problem and was suggested as solution on a Danish IT forum.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQLite with Mobile Development 4 25
First Max value 3 31
SQL Group By Question 4 20
MS SQL Conditional WHERE clause 3 15
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question