C# 如何打开 *.sdf 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2375118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:53:34  来源:igfitidea点击:

how to open *.sdf files?

c#visual-studio-2008sql-server-ce

提问by Gold

I used to open sdf (sqlCE) files with visual-studio? or sql-server? I really don't remember. Now I can't open this sdf file. With what program do I need to open it?

我曾经用visual-studio打开sdf(sqlCE)文件?或 sql 服务器?我真的不记得了。现在我无法打开这个 sdf 文件。我需要用什么程序打开它?

采纳答案by ctacke

It's a SQL Compact database. You need to define what you mean by "Open". You can open it via code with the SqlCeConnection so you can write your own tool/app to access it.

它是一个 SQL Compact 数据库。您需要定义“打开”的含义。您可以使用 SqlCeConnection 通过代码打开它,以便您可以编写自己的工具/应用程序来访问它。

Visual Studio can also open the files directlyif was created with the right version of SQL Compact.

如果使用正确版本的 SQL Compact 创建,Visual Studio 也可以直接打开文件

There are also some third-party toolsfor manipulating them.

还有一些第三方工具可以操作它们。

回答by Phil Ross

In addition to the methods described by @ctacke, you can also open SQL Server Compact Edition databases with SQL Server Management Studio. You'll need SQL Server 2008 to open SQL CE 3.5 databases.

除了@ctacke 描述的方法之外,您还可以使用 SQL Server Management Studio 打开 SQL Server Compact Edition 数据库。您将需要 SQL Server 2008 才能打开 SQL CE 3.5 数据库。

回答by Chris Voon

Try LINQPad, it works for SQL Server, MySQL, SQLite and also SDF (SQL CE 4.0). Best of all it's free!

试试LINQPad,它适用于 SQL Server、MySQL、SQLite 和 SDF (SQL CE 4.0)。最重要的是它是免费的!

LINQPad

LINQPad

Steps with version 4.35.1:

版本 4.35.1 的步骤:

  1. click 'Add Connection'

  2. Click Next with 'Build data context automatically' and 'Default(LINQ to SQL)' selected.

  3. Under 'Provider' choose 'SQL CE 4.0'.

  4. Under 'Database' with 'Attach database file' selected, choose 'Browse' to select your .sdf file.

  5. Click 'OK'.

  6. Voila! It should show the tables in .sdf and be able to query it via right clicking the table or writing LINQ code in your favorite .NET language or even SQL. How cool is that?

  1. 点击“添加连接”

  2. 单击下一步并选择“自动构建数据上下文”和“默认(LINQ to SQL)”。

  3. 在“提供者”下选择“SQL CE 4.0”。

  4. 在选择了“附加数据库文件”的“数据库”下,选择“浏览”以选择您的 .sdf 文件。

  5. 单击“确定”。

  6. 瞧!它应该以 .sdf 格式显示表格,并且能够通过右键单击表格或使用您喜欢的 .NET 语言甚至 SQL 编写 LINQ 代码来查询它。多么酷啊?

回答by user_v

You can use SQL Compact Query Analyzer

您可以使用 SQL Compact 查询分析器

http://sqlcequery.codeplex.com/

http://sqlcequery.codeplex.com/

SQL Compact Query Analyzer is really snappy. 3 MB download, requires an install but really snappy and works.

SQL Compact 查询分析器真的很活泼。3 MB 下载,需要安装,但非常快速且有效。

回答by Nikhil Sahu

If you simply need to view the table and run queries on it you can use thisthird party sdf viewer. It is a lightweight viewer that has all the basic functionalities and is ready to use after install.

如果您只需要查看表并对其运行查询,则可以使用第三方 sdf 查看器。它是一个轻量级的查看器,具有所有基本功能,安装后即可使用。

and ofcourse, its Free.

当然,它是免费的。

回答by Hameed Syed

It can be opened using Visual Studio 2012.Follow the below path in VS after opening the project. View->Server Explorer->

它可以使用Visual Studio 2012打开。打开项目后,请在VS中按照以下路径进行操作。查看->服务器资源管理器->

enter image description here

在此处输入图片说明