在另一台PC上使用本地数据库的项目无效 [英] Project with local database on another pc not working

查看:120
本文介绍了在另一台PC上使用本地数据库的项目无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我有一个项目与本地数据库完美地在我的电脑上工作,但当我在另一台PC上复制它不起作用。我在另一台PC上安装了SqlLocalDb.msi文件,但它仍无法正常工作。这是我的连接字符串:



我尝试过:



Hi. I have a project with local database perfectly working on my PC but when I copy it on another PC it is not working. I have installed SqlLocalDb.msi file on another PC but still it is not working. This is my connection string:

What I have tried:

<>string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ProfessorDb.mdf;Integrated Security=True;User Instance=True";







你能帮我吗?




Can you please help me?

推荐答案

首先,如果你想共享数据,那么不要扩散SQL实例:使用单个所有需要共享数据的计算机都可以看到的实例,并且不附加数据库 - 在SQL Server实例中创建它并使用它。附加完全是一个不同的过程,它只为您的应用创建一个本地副本:坏习惯:使用AttachDBFileName - SQL Sentry [ ^ ]

如果您不想共享数据,请不要使用SQL Server:使用Access,SQLCE或SQLite,因为它们不需要安装服务器。
First off, if you want to share data, then don't proliferate SQL instances: use a single instance that is visible to all machines that need to share the data, and don't attach a database - create it in the SQL server instance and use that. Attaching is a different process entirely, and it creates a "local copy" for your app's use only: Bad habits : Using AttachDBFileName - SQL Sentry[^]
If you don't want to share data, then don't use SQL Server: use Access, SQLCE, or SQLite instead as they require no server installation.


这篇关于在另一台PC上使用本地数据库的项目无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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