[英]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.