在运行时加载和保存 .sdf

发布于 2024-12-23 07:26:14 字数 270 浏览 5 评论 0原文

我正在构建一个 C# 应用程序,该应用程序使用 SQL Server Compact 4.0 数据库 (.sdf) 和实体框架来存储数据。我希望能够从此应用程序中加载/保存文件,以便用户可以加载不同的数据库或将数据库备份到 USB,例如。

我知道你可以在代码中创建一个 sdf,但是我如何在运行时加载它(连接字符串)?

我的问题是,这一定是一件常见的事情,最好的方法是什么?有没有任何指南可以做到这一点?

或者你推荐另一种方法来解决我的问题吗?

//目标编码器

I'm building an C#-application that uses an SQL Server Compact 4.0 database (.sdf) with Entity Framework for data. I want to be able to load/save-files from within this application so that the user can load a different database or backup the database to an USB eg.

I know you can create an sdf in code, but how can i load it at runtime (The connectionstring)?

My question is that this must be a common thing to do, what is the best way to go about it? is there any guides out there to do this?

or do you reccomend another way to go about my problem?

//ObjectiveCoder

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

游魂 2024-12-30 07:26:14

您应该使用 SqlCeConnectionStringBuilder 创建包含文件路径的连接字符串。

You should use a SqlCeConnectionStringBuilder to create a connection string containing your file path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文