天道酬勤,学无止境

mdf

How to run an SQL script against a MDF file?

问题 我使用 Entity Framework 4.0 使用模型优先方法创建了一个数据库模型。 然后我使用从模型生成数据库创建了一个 sql 脚本...我还在我的 App_Data 文件夹中创建了一个 SQL Server 数据库文件。 我现在如何针对这个 MDF 文件运行 SQL 文件? 我正在使用 Visual Studio 2010。 回答1 我遇到了同样的问题,这对我有用。 当我选择“从模型生成数据库...”时,我创建了一个新的 MDF 文件。 此过程运行良好,Visual Studio 生成了所需的 SQL 脚本。 但是,我不知道如何连接到同一个 MDF 文件来运行脚本。 事实证明这很容易。 右键单击脚本并选择连接 > 连接应该已经为本地 SQLEXPRESS 实例设置了服务器名称和身份验证。 单击选项按钮单击附加连接参数选项卡使用以下指导粘贴数据库文件的路径: AttachDBFilename=C:\Path\To\Database\LocalData.mdf;database=LocalData; 单击连接按钮 如果您仍然无法连接,可能是因为已经有一个打开的连接。 检查服务器资源管理器,如果连接已打开,请右键单击并选择关闭连接。 只要 SQL 脚本保持连接,此过程还将创建持久连接。 您将要关闭脚本或选择右键单击 > 连接 > 断开连接。 更多信息可以在这个问题上找到

2022-05-16 04:08:03    分类:技术分享    .net   entity-framework-4   mdf   sql-scripts   ef-model-first

Attach (open) mdf file database with SQL Server Management Studio [closed]

问题 关闭。 此问题不符合 Stack Overflow 准则。 它目前不接受答案。 想改进这个问题? 更新问题,使其成为 Stack Overflow 的主题。 5 个月前关闭。 社区在5 个月前审查了是否重新打开此问题并将其关闭: 原始关闭原因未解决改进这个问题 如何在 SQL Server Management Studio 中打开使用 Visual Studio 2010 创建的数据库的*.mdf文件? 我试图自己附加它,但出于(我猜)某些安全原因,我无法导航到该文件。 回答1 我有同样的问题。 系统配置:-单系统window 7 sp1服务器和客户端都安装在同一个系统上 我试图访问窗口桌面。 正如一些答案所说,您的 Sqlserver 服务没有对​​该目录的完全访问权限。 这是完全正确的。 我通过几个简单的步骤解决了这个问题 转到所有程序 -> microsoft sql server 2008 -> 配置工具,然后选择 sql server 配置管理器。 选择服务并转到属性。 在构建帐户对话框中选择本地系统,然后选择确定按钮。 图像中的第 3 步和第 4 步是访问文件夹的演示 回答2 回答3 我发现这篇关于如何在 SQL Server Management Studio 中打开(附加)MDF 文件的详细帖子:http://learningsqlserver

2022-05-06 13:46:04    分类:技术分享    sql-server   visual-studio-2010   mdf

Attach (open) mdf file database with SQL Server Management Studio [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 months ago. The community reviewed whether to reopen this question 5 months ago and left it closed: Original close reason(s) were not resolved Improve this question How can I open a *.mdf file of a database created with Visual Studio 2010, into SQL Server Management Studio? I tried to attach it by myself, but I cannot navigate to that file for (I guess) some security reason.

2022-04-29 01:40:34    分类:问答    sql-server   visual-studio-2010   mdf

How to run an SQL script against a MDF file?

I've created a database model with model-first method using Entity Framework 4.0. I then created an sql script using the Generate Database from Model... I've also created an SQL Server Database file in my App_Data folder. How do I now run the SQL file against this MDF file? I'm using Visual Studio 2010.

2022-04-27 13:56:54    分类:问答    .net   entity-framework-4   mdf   sql-scripts   ef-model-first

C# mdf 数据库在程序启动时不更新(C# mdf database doesn't update on program startup)

问题 I create simple example to create question easyer. So in my c# project I create an mdf database with articles. Then I connect database in my program and read values from table articles. It gives me results, but not the latest. If I have one result it showes me this one. Then I go in articles table to add one new article and run program again and in this case program showes me only the first one. But if I "Build solution" it finds all of them. What I have to do? I wish, that program will have the latest result on startup. SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS

2022-04-18 08:25:04    分类:技术分享    c#   mdf

C# mdf database doesn't update on program startup

I create simple example to create question easyer. So in my c# project I create an mdf database with articles. Then I connect database in my program and read values from table articles. It gives me results, but not the latest. If I have one result it showes me this one. Then I go in articles table to add one new article and run program again and in this case program showes me only the first one. But if I "Build solution" it finds all of them. What I have to do? I wish, that program will have the latest result on startup. SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS

2022-04-17 07:33:17    分类:问答    c#   mdf

Hibernate: connection.url for SQL Server .MDF File

How do I Hibernate connection.url for SQL Server .MDF File? I've tried prop.setProperty("hibernate.connection.url", "jdbc:sqlserver://c:\\db.mdf"); but don't work :( Thx!

2022-04-16 09:10:38    分类:问答    java   sql-server   hibernate   mdf

Converting MDF to SDF

I've done a bit of Googling trying to find out how to convert a .MDF file to a .SDF. There doesn't seem to be much around apart from an old article for something called 'SQL Server to SQL Server Compact Edition Database Copy Utility'. As this is so old, I doubt it will work with the newer versions of SQL Server databases. Is there a more established and official method of achieving this now? Ideally I need something that will migrate the data as well as the table structures.

2022-03-22 13:41:36    分类:问答    sql-server   sql-server-ce   mdf   sdf

How to prevent LocalDB from detaching MDF file after some idle time?

I'm building a .NET 4.5 (winforms) application that uses LocalDB to work with a local MDF file, using this connection string: Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\DB\DatabaseFile.mdf;Integrated Security=True;MultipleActiveResultSets=True When I run my application, the first SQL query takes some time to execute - nothing drastic, about 2 or 3 seconds. After that, all next SQL queries are executed instantly. I assume that the extra seconds during the first execution are needed to attach the MDF file to a local SQL Server service. Right? I noticed, however, that if 10

2022-03-17 12:06:48    分类:问答    c#   .net   winforms   localdb   mdf