CoolStraw
CoolStraw

Reputation: 5390

Multiple queries

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.

Upvotes: 1

Views: 523

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038830

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.

Upvotes: 1

Related Questions