Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have developed application window form with C# by connect to MDF file. It work on my computer but other computer can not connect to MDF file.
Posted
Comments
Kornfeld Eliyahu Peter 22-Jul-15 2:25am    
Do you have any error while connection?
Can you show us the relevant code?
northboy dokhamtai 22-Jul-15 2:32am    
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 configure to allow remote connection. (provider: SQL Network Interfaces; error: 26 - Error Locating Server/Instance Specified)
Kornfeld Eliyahu Peter 22-Jul-15 2:38am    
It seems to me that your connection string try to connect to a server and not directly to the MDF file...
Please share you connection string s owe can examine it...
northboy dokhamtai 22-Jul-15 2:36am    
I am not sure that I need to install SQL server on other computer. I just move MDF file from my project to there.
Suvendu Shekhar Giri 22-Jul-15 2:34am    
Can you share your connection string?

From your comments it is clear that you try to connect to an instance (local instance) of an SQL (express edition) which obviously does not exists...
You have 3 options:
1. Embed your database in the application, so when you package your application the installer will contain also the necessary SQL engine
2. Install a local copy of SQL and attach the mdf fie to it
3. Use a remote SQL server from every computer
 
Share this answer
 
Comments
northboy dokhamtai 22-Jul-15 4:58am    
Can you explain me if I need to use option 1? How to make it? Thank you.
The problem most likely is that the instance name is wrong or the instance is not up and running on your local computer.

See SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified[^]
 
Share this answer
 
v2
Now I can use MDF file on other computer by:
- Made package installer for my program.
- Installed SQL Server Express on other computer which will run it on
- Installed program follow setup wizard
- Set authorize access for MDF file

So that I can run my program without any error

Thank you Kornfeld Eliyahu Peter and Suvendu Shekhar Giri for your help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900