Hello,
I'm build a web page in ASP.net is supposed to work just like Query Analyzer. It has basically a textarea to input the sql command, and an Execute button.
I'm using SMO to execute the command in the database, as follows:
//Create object SMO
Microsoft.SqlServer.Management.Smo.Server server = new Microsoft.SqlServer.Management.Smo.Server(new Microsoft.SqlServer.Management.Common.ServerConnection(oConn));
//To execute the command
server.ConnectionContext.ExecuteNonQuery(tbx_cmd.Text);
//OR
myDataset = server.ConnectionContext.ExecuteWithResults(tbx_cmd.Text);
The problem is that the textarea command can contain anything, from a stored procedure (with GO's statements) and any select command that return resultsets, just like Query Analyzer.
But, if I have GO statements, I only can perform the query using ExecuteNonQuery method. If I use the ExecuteWithResults method, it raises errors because of the GO statements.
And if I want the resultsets to be available, of course I can only use the ExecuteWithResults method.
Does anybody knows how can I do to execute the same command texts at the same time?
Thank you!