无法连接到我自己的 MDF 文件.无法打开用户默认数据库.登录失败.用户登录失败...和其他错误 [英] Can't connect to my own MDF file. Cannot open user default database. Login failed.Login failed for user... and other errors

查看:120
本文介绍了无法连接到我自己的 MDF 文件.无法打开用户默认数据库.登录失败.用户登录失败...和其他错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQLSEXPRESS 服务正在运行!!

我有我前段时间写的程序,它可以工作.它是用 MS Visual Studio 编写的,带有本地 MDF 文件.

I have I program I wrote some time ago and it works. It was written in MS Visual Studio with local MDF file.

如何从 Microsoft SQL Server Management Studio 编辑此文件?我在全局连接的数据库列表中没有看到这个文件.

How is it possible to edit this file from Microsoft SQL Server Management Studio? I don't see this file in the list of globally connected databases.

如果我尝试使用 Visual Studio 向导附加这个文件,我会收到这样的数据库已经存在的消息,但是当我设置任意逻辑名称时,我会收到共享冲突.

If I try to attach this file with Visual Studio Wizard, I get message that such database already exists, but when I set arbitrary logical name, I get sharing violation.

如何访问 MDF 文件?

How to reach MDF file?

编辑 1

现在我发现我的程序也停止工作了.

Now I found that my program also stopped to work.

不同尝试访问 MDF 文件的结果汇总:

The summary of results of different attempts to reach MDF file:

  1. 程序本身 System.Data.SqlClient.SqlException (0x80131904):无法打开用户默认数据库.登录失败.用户 登录失败.(Windows 用户)
  2. Visual Studio,数据源 = Microsoft SQL Server,逻辑名称 = "" 错误消息:尝试为文件附加自动命名的数据库 失败.存在同名的数据库,或无法打开指定的文件,或者它位于 UNC 共享上.
  3. Visual Studio,数据源 = Microsoft SQL Server,逻辑名称 = SOMENAME 错误消息 无法打开物理文件 .操作系统错误 32:32(该进程无法访问该文件,因为它正被另一个进程使用)".无法附加文件 作为数据库SOMENAME".
  4. Visual Studio,数据源 = Microsoft SQL Server 数据库文件,Windows 身份验证错误消息:无法打开用户默认数据库.登录失败.用户 登录失败.
  5. Visual Studio,数据源 = Microsoft SQL Server 数据库文件,SQL Server 身份验证错误消息:无法生成 SQL Server 的用户实例.只有集成连接才能生成用户实例.连接将被关闭.
  6. Microsoft SQL Server Management Studio,附加数据库错误消息:无法打开物理文件 .操作系统错误 32:32(该进程无法访问该文件,因为它正被另一个进程使用)".(Microsoft SQL Server,错误:5120)
  1. Program itself System.Data.SqlClient.SqlException (0x80131904): Cannot open user default database. Login failed. Login failed for user <username>. (windows user)
  2. Visual Studio, Data source = Microsoft SQL Server, Logical Name = "" Error message: An attempt to attach an auto-named database for file <filename> failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
  3. Visual Studio, Data source = Microsoft SQL Server, Logical Name = SOMENAME Error message Unable to open the physical file <filename>. Operating system error 32: "32(The process cannot access the file because it is being used by another process )". Cannot attach the file <filename> as database ‘SOMENAME’.
  4. Visual Studio, Data source = Microsoft SQL Server Database File, Windows Authentication Error message: Cannot open user default database. Login failed. Login failed for user <username>.
  5. Visual Studio, Data source = Microsoft SQL Server Database File, SQL Server Authentication Error message: Failed to generate a user instance of SQL Server. Only an integrated connection can generate a user instance. The connection will be closed.
  6. Microsoft SQL Server Management Studio, Attach Database Error message: Unable to open the physical file <filename>. Operating system error 32: "32(The process cannot access the file because it is being used by another process)". (Microsoft SQL Server, Error: 5120)

推荐答案

试试这个:

1- 创建一个与 mdf 文件同名的数据库.

1- Create a database with the same name to mdf file.

2- 停止 sql 服务

2- Stop sql service

3- 转到所有 mdf 文件和 ldf 所在的数据地毯,复制原始 mdf 文件并替换.

3- Go to the Data Carpet where is all mdf files and ldf , copy your original mdf file y replace.

4- 启动服务

5- 在管理工作室查看数据库是否仍然在线.

5- See in the management studio if the database still online there you go.

这篇关于无法连接到我自己的 MDF 文件.无法打开用户默认数据库.登录失败.用户登录失败...和其他错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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