我正在将 Visual Studio 2010 C# Express 和 SQL Server Management Studio 与 SQL Server 2012 一起使用,当我尝试将数据库连接到我的 Windows 窗体项目时出现错误。
"This file is in use. Enter a new name or
close the file that is open in another program"
我在网上四处寻找解决方案,但没有奏效。所以我决定创建一个全新的数据库和一个全新的项目。但我仍然得到错误!
这是我使用的步骤:
- 首先我连接到我的本地托管服务器
- 然后我右键单击
Databases并选择New Database并命名它school - 然后我右键单击
tables新数据库上的文件夹并选择new table - 我添加了这些表
student, course, enrolled - 最后我在里面扔了一些虚假的条目
现在我跳到 VS
- 我选择
New Project然后Windows Forms Application命名它Registrar - 然后我点击
add new data source database在Choose a data source type窗口 中选择- 然后我
Dataset在Choose a Database Model窗口 中选择 - 然后我单击
New Connection更改数据源以Microsoft SQL Server Database File浏览到我的“SQLEXPRESS”文件夹中的 DATA 文件夹,当我单击“school.mdf”文件时出现上述错误。
任何帮助将不胜感激。