Capturing PRINT statements from Stored Procedure in C#
public class StoredProcedure { private static ILog log = LogManager.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType); static public void Execute (DBSqlPath path , int connectionTimeout, int commandTimeout, string storedProcedureName, SqlParameter[] parameters ) { SqlInfoMessageHandler handler = new SqlInfoMessageHandler(); using (DBConn conn = new DBConn( path , connectionTimeout)) { conn.OpenConnection(); conn.SqlConnection.InfoMessage += handler.connection_InfoMessage; SqlCommand command = new SqlCommand(storedProcedureName, conn.SqlConnection); command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = commandTimeout; foreach (SqlParameter param in parameters ) { command. Parameters . Add (param); } try { command.ExecuteNonQuery();