Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hi,

i create a program with c# that connect to MDF DB File in folder on the same computer by this code

C#
public static string s_Coonn = "Server=.\\SQLExpress;AttachDbFilename="+@"D:\JES\JES CoSalesdb\jes_cosalesdb.mdf"+";Database=jes_cosalesdb; Trusted_Connection=Yes";


can i install my program on another pc without installing sql or move the DB file ?
Posted
Comments
Suvendu Shekhar Giri 24-Nov-15 20:38pm    
As far I know, No, you can't share the mdf file across the intranet or internet. If you want to access the same database over a network then you have to install SQL Server in one of your system which will behave as a server.
Golden Basim 25-Nov-15 2:02am    
but i use localdb

1 solution

Well you need to not use AttachDbFilename when you connect. That is change your connection string to a more standard one.
https://msdn.microsoft.com/en-us/library/jj653752%28v=vs.110%29.aspx[^]

Then enable network access to your database
https://technet.microsoft.com/en-us/library/ms165718(v=sql.105).aspx[^]

You have to decide if you want to use integrated security, in which case connecting user will have to have rights for the database, or perhap make an application user which just goes into the connection string using MSSQL server authentication and which can be shared.
 
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