PreviousData Provider for .NET Guide (9.1 revision 1) Next

Retrieving Warning Information

Show this topic in Library frames

The data providers handle database server warnings through the InfoMessage delegates on the Connection objects.

The following example shows how to retrieve a warning from a Pervasive.SQL server:

// Define an event handler 
public void myHandler(object sender, 
PsqlInfoMessageEventArgs e) 
{ 
    // Display any warnings in a messagebox 
    MessageBox.Show (e.Message,"This is a Warning."); 
} 

Add the following code to a method and call it.

PsqlConnection  Conn; 
Conn = new PsqlConnection("ServerDSN=Demodata; 
								UID=test; 
								PWD=test; 
                           Server=localhost;"); 
PsqlCommand   DBCmd = new PsqlCommand("print 'This is a 
Warning.'", Conn); 
PsqlDataReader  myDataReader; 
try  
{ 
    Conn.InfoMessage += new 
PsqlInfoMessageEventHandler(myHandler); 
    Conn.Open(); 
    myDataReader = DBCmd.ExecuteReader(); 
    // This will throw a PsqlInfoMessageEvent as the print 
    // statement generates a warning. 
} 
catch (Exception ex)  
{ 
    // Display any exceptions in a messagebox 
    MessageBox.Show (ex.Message); 
} 
//  Close the connection 
Conn.Close(); 

Chapter contents
Publication contents

Prev topic: Calling a Stored Procedure
Next topic: Inserting Data Into LONGVARCHAR and LONGVARBINARY Columns