C# 和参数化 SQLite,无需通过 ADO.NET

发布于 2024-07-25 13:01:19 字数 218 浏览 3 评论 0原文

是否可能,如果可以,如何...使用 SQLite 进行参数化查询,而无需通过 ADO.NET。 我被要求对需要零管理安装的项目使用 SQLite 进行一些测试...即:没有特殊权限、添加到 Windows 注册表的内容等。我怀疑使用 ADO.NET 会需要这样的,即使 SQLite 只是项目目录中的一个 DLL。

是的,我确实理解参数化查询的重要性以及如果不安全处理 SQL 注入可能出现的问题。

Is it possible, and if so, how... To do parameterized queries with SQLite WITHOUT having to go through ADO.NET. I've been asked to do some testing with SQLite for a project that needs to have a zero-admin install... ie: no special permissions, things added to windows registry, etc. I would suspect that using an ADO.NET would require such, even though SQLite is just a DLL sitting in the project directory.

And yes, I do understand the importance of parameterized queries and issues that can arise out of SQL-Injection if not handled safely.

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

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

发布评论

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

评论(1

不一样的天空 2024-08-01 13:01:35

是什么让您认为 ADO.NET 需要注册表项等? 事实并非如此。 您只需要安装 .NET 和适当的提供程序集。

现在,您不需要 ADO.NET 的全部 - 例如,您很可能不需要 DataTable/DataSet 支持,如果您很高兴自己使用适当的 DataReader 类型 - 但同样,如果您确实想要使用它们(即使是强类型版本),则不需要任何特殊设置。

当然,SQLite 提供程序可能对注册表有自己的要求,但我对此非常怀疑。 这将违背我的“正常”ADO.NET 提供程序体验,也违背 SQLite 的正常使用。

我希望有各种 SQLite 提供程序。 例如,这里结合了.NET部分本机代码SQLite 本身,所以据我所知,只有一个 DLL 可以与您的应用程序一起部署。 没有比这更简单的了。

What makes you think that ADO.NET would require registry entries etc? It doesn't. You just need .NET installed and the appropriate provider assembly.

Now, you won't need all of ADO.NET - for instance, you may well not need the DataTable/DataSet support, if you're happy to use the appropriate DataReader type yourself - but again, if you do want to use them (even strongly typed versions) you shouldn't need any special settings.

Of course, it's possible that the SQLite provider has its own requirements around the registry, but I very much doubt it. That would go against my "normal" ADO.NET provider experience, as well as being against the normal usage of SQLite.

I expect there are various SQLite providers. For instance, there's one here which combines the .NET part and the native code of SQLite itself, so there's just the single DLL to deploy alongside your application, as far as I can tell. It doesn't get much simpler than that.

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