VistaDB 5
Gibraltar VistaDB > Developer's Guide > SQL Reference > Functions > Special Functions > PRINT > Subscribing to PRINT output in your application
Subscribing to PRINT output in your application
The PRINT command sends informational messages through the VistaDBConnection object. Any application may subscribe to these messages. The Data Builder application currently subscribes to them and outputs them as a part of the Log for the command.

Print Message Sample
Copy Code
public void PrintMessage()
            bool gotMessage = false;

            using (IVistaDBDatabase db = DDAObj.OpenDatabase(dbName, VistaDBDatabaseOpenMode.ExclusiveReadWrite, null))
                using (VistaDB.Provider.VistaDBConnection connection = new VistaDB.Provider.VistaDBConnection(db))
                    connection.InfoMessage += 
              new VistaDBInfoMessageEventHandler(
                  delegate(object sender, VistaDBInfoMessageEventArgs args)
                                 gotMessage = true;

                    using (VistaDB.Provider.VistaDBCommand command = connection.CreateCommand())
                        command.CommandType = CommandType.Text;
                        command.CommandText = "PRINT 'Test'";



This example uses an inline delegate as a part of an NUnit test to verify the print event was triggered correctly.

You could use a function within your application for the notification as well.

Performance Considerations

Note that any calls to your application print event handler are run as the line is being executed in the SQL script. Any long running commands as a part of the callback will slow down overall execution of the SQL.

See Also