I am using SMO
I am having hard time to capture result (it could be syntax error message or set of result with data) just like we get in SQL Server Management Studio. I tried several example that I found on internet, but could not make it work as I wanted.
I tried the following two syntaxs
//I am trying catch errors here
int[] results = DBServer.ConnectionContext.ExecuteReader("select * from SomeNonExistingTable");
//I am trying to catch result sets as dataset here
//But I cannot implicitly convert to dataset here using C#
DataSet ds = databaseServer.ConnectionContext.ExecuteWithResults("Select * from mytable");
I tried to get some idea from the following Websites:
SMO ConnectionContext.StatementTimeout setting is ignored
Using SMO, still no go... ConnectionContext.ExecuteNonQuery(script) can't understand "GO"