到mdf文件的多个连接 [英] multiple connections to an mdf file

查看:97
本文介绍了到mdf文件的多个连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c#为大学项目创建.Net应用程序,需要一些帮助!

im creating a .Net application using c# for a university project and need some help!

我在网络驱动器上托管有一个mdf文件,并且需要多个客户端才能从其应用程序访问此数据库.每台客户端计算机都将运行自己的sql express实例.

I have a mdf file hosted on a network drive and need several clients to be able to access this database from their applications. Each client machine will be running their own instance of sql express.

我可以从我的应用程序访问文件,但是当另一个客户端尝试访问它们时,会收到以下错误消息

I can access file from my application, but when another client tries to they receive the following error message

无法打开用户默认数据库.登录失败. 用户'EEEC \ 40023753'登录失败.

Cannot open user default database. Login failed. Login failed for user 'EEEC\40023753'.

数据库状态配置为允许多个用户

The database state is configured to allow multiple users

我当前使用的连接字符串是:

The Connection String I am currently using is :

数据源=.\ SQLEXPRESS; AttachDbFilename = \\ servxxx.eeecs.qub.ac.uk \ Virtual_Directories \ level3 \ cs8 \ App_Data \ cs4_database.mdf;集成安全性= True;连接超时= 30;用户实例=是"

"Data Source=.\SQLEXPRESS;AttachDbFilename=\\servxxx.eeecs.qub.ac.uk\Virtual_Directories\level3\cs8\App_Data\cs4_database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

任何评论将不胜感激!

推荐答案

您需要在网络服务器上托管数据库服务器.几个客户端可以连接到SQL Server服务.但是几个客户端不能同时直接连接到mdf文件.

You need to host the database server on the network server. Several client can connect to the SQL Server Service. But several clients cannot simultaneously connect directly to the mdf file.

仅文件无法处理并发.您可以与数据库服务器建立多个连接.数据库软件负责处理并发.

The file alone cannot handle concurrency. You can have multiple connection to a database server. The database software is what handles the concurrency.

这篇关于到mdf文件的多个连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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