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'"; command.ExecuteNonQuery(); } } } Assert.IsTrue(gotMessage); } |
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.