简体   繁体   English

如何使2个应用程序使用SQL Server Express访问相同的mdf文件

[英]How to get 2 applications accessing same mdf file with SQL Server Express

I have two .NET applications, one running on 2.0 and the other running on 4.5. 我有两个.NET应用程序,一个运行在2.0上,另一个运行在4.5上。

The .NET 2.0 application is the main application where the user inputs data and this runs perfectly. .NET 2.0应用程序是用户输入数据且可以完美运行的主要应用程序。 The .NET 4.5 application is a Telerik Reporting site that runs a report based on data entered in the 2.0 application and is receiving the error below .NET 4.5应用程序是一个Telerik Reporting站点,该站点基于在2.0应用程序中输入的数据运行报告,并收到以下错误消息

system error 32 (the process cannot access the file because it is being used by another person) 系统错误32(该进程无法访问该文件,因为该文件正在被其他人使用)

Both applications are using this the connection strings below. 两个应用程序都使用下面的连接字符串。

<add name="sqlserver" 
     connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=c:\FolderName\Database.mdf;Integrated Security=True;User Instance=True" 
     providerName="System.Data.SqlClient"/>

I set up SQL Server Express to use windows authentication but I can't seem to get it to work. 我将SQL Server Express设置为使用Windows身份验证,但似乎无法使其正常工作。 Any help would be greatly appreciated. 任何帮助将不胜感激。

You can't. 你不能 SQL Server process holds a lock on the file while it's up and running. SQL Server进程在文件启动和运行时会对其进行锁定。 But alternatively, you can setup a database server and point both apps to the same database. 但是,您也可以设置数据库服务器,并将两个应用程序都指向同一个数据库。 Or have two instances with replication. 或者有两个具有复制的实例。 Database files are good for development, but not to be used in production environments. 数据库文件有利于开发,但不能在生产环境中使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式备份​​SQL Server 2014 Express Localdb(.mdf)文件 - How to backup a SQL Server 2014 Express Localdb (.mdf) file programmatically 如何在Visual Studio中添加SQL Server数据库文件(.mdf)而不安装SQL Server Express Edition? - How to add SQL Server database file (.mdf) in Visual Studio without installing SQL Server Express Edition? 如何在没有Management Studio的情况下将数据库mdf文件附加到SQL Server Express? - How to attach database mdf file to SQL Server Express without Management Studio? 如何在安装了SQL Express 2012但仍保留为SQL Express 2005的C#中附加mdf文件? - How to attach a mdf file in C# with SQL Express 2012 installed but keep as SQL Express 2005? 如何以编程方式将.MDF文件附加到Azure SQL Server C# - How to attach .MDF file to Azure SQL Server programmatically c# 如何加密MS SQL附加的mdf文件(用户实例SQL Express) - How to encrypt MS SQL attached mdf file (user instance SQL Express) 将数据库(.mdf文件)附加到SQL Server时出错 - Error attaching a database (.mdf file) to SQL Server 是否有任何机制来保护我的.mdf文件在SQL Server Express 2008中? - Is there any mechanism to secure my .mdf files in SQL Server Express 2008? SQL Express连接字符串:相对于应用程序位置的mdf文件位置 - SQL Express connection string: mdf file location relative to application location 如何还原对其MDF和LDF文件使用相同命名方案的多个SQL Server数据库 - How to restore multiple SQL Server databases that use the same naming scheme for their MDF and LDF files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM