多次查询

发布于 2024-10-02 23:02:02 字数 239 浏览 0 评论 0原文

我有一个 ADO.NET 问题,确实,我想知道是否可以执行盲查询;这意味着用户在文本框中输入任何内容(应该是 SQL 或 T-SQL 语句),然后当他提交时我想即时执行其输入,我已经看到 ADO.NET 有SELECT 和 INSERT/DELETE/UPDATE 语句的方法不同,所以总而言之,有没有办法只执行一堆语句而不先检查它们的类型? (查询可能包含“;”分隔的查询,所以......)

提前致谢,

Miloud Bel。

I've got a ADO.NET question, Indeed, I'd like to know if it's possible to do blind query execution; which means the user enters anything in a text box (well it's supposed to be SQL or T-SQL statement(s)), then when he submits I want to execute its input on the fly, I've seen that ADO.NET has different methods for SELECT and INSERT/DELETE/UPDATE statements, so to conclude, is there a way to just execute a bunch of statements without checking their kind first ? (the query could contain ";" separated queries so...)

Thanks in advance,

Miloud Bel.

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

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

发布评论

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

评论(1

娇柔作态 2024-10-09 23:02:02

如果您的数据库支持多个语句,您可以使用 ; 将它们分开并一次性执行:sqlCommand.ExecuteNonQuery();。当然,如果您在同一查询中混合使用 SELECT、UPDATE、DELETE,则获取结果可能会很混乱。您还可以检查此示例

If your database supports multiple statements you could separate them with ; and execute in one go: sqlCommand.ExecuteNonQuery();. Of course fetching the results could be messy if you mix SELECT, UPDATE, DELETE in the same query. You may also check this sample.

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