-1

I am trying to make a Database work bench application using WPF in C#. I was wondering if there is a way to execute multiple SQL queries of different type like Select, update and delete. All in one shot. Because I won't be able to use ExecuteNonQuery or ExecuteQuery since some statements will return data (Select) and some won't (Insert).

Also I won't be able to tell where does each query end because it will be one big textbox that has all of them, something like SSMS.

Anyone knows how to execute those statements at once? And how would I be able to retrieve every table returned if any?

ASh
  • 34,632
  • 9
  • 60
  • 82
Zeyad
  • 537
  • 2
  • 7
  • 15

1 Answers1

2

You can just send a batch of statements to SQL Server for execution. The only issue for you is that you need to deal with multiple result sets being returned. Take a look at the NextResultSet method.

Also, if you're building something like SSMS, don't forget to allow for batch separators like GO, as they aren't commands, and you need to pull apart the batches and send them separately to the server.

Greg Low
  • 1,526
  • 1
  • 4
  • 4