如何连接到另一个PC上的文件夹中的本地Mdf Db文件 [英] How I Can Connect To A Local Mdf Db File In Folder On Another Pc

查看:87
本文介绍了如何连接到另一个PC上的文件夹中的本地Mdf Db文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用c#创建一个程序,通过此代码连接到同一台计算机上文件夹中的MDF DB File

 公共 静态 字符串 s_Coonn = "  +  @"   D:\ JES \ JES CoSalesdb \ jes_cosalesdb.mdf" +  ; Database = jes_cosalesdb; Trusted_Connection =是";



我可以在不安装sql或移动数据库文件的情况下在另一台PC上安装我的程序吗?

解决方案

那么,连接时无需使用AttachDbFilename.那就是将您的连接字符串更改为更标准的字符串.
https://msdn.microsoft.com/en-us/library/jj653752%28v = vs.110%29.aspx [ ^ ]

然后启用对数据库的网络访问
https://technet.microsoft.com/en-us/library/ms165718 (v = sql.105).aspx [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 ?

解决方案

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.


这篇关于如何连接到另一个PC上的文件夹中的本地Mdf Db文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆