Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot Open .mdf Database in Windows Application

Posted on 2016-07-27
7
Medium Priority
?
56 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Viewers will learn how the fundamental information of how to create a table.

722 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