I am trying to execute DBCC CHECK DB('MyDB) using ADO.Net, but how can I get the text returned by the command?
I have tried the following:
SqlCommand sqlCom = new SqlCommand("DBCC CHECKDB ('MyDB')", sqlCon);
SqlParameter output = new SqlParameter();
output.Direction = System.Data.ParameterDirection.ReturnValue;
sqlCom.Parameters.Add(output);
int result = sqlCom.ExecuteNonQuery();
Console.WriteLine(output.Value);
But the output parameter value is empty.