You can use the standard .NET error-handling features to handle errors. Most UltraLite methods throw ULException errors. You can use ULException.NativeError to retrieve the ULSQLCode value assigned to this error. ULException has a Message property, which you can use to obtain a descriptive text of the error. ULSQLCode errors are negative numbers indicating the error type.
For a list of error codes, see Error Messages.
After synchronization, you can use the SyncResult property of the connection to obtain more detailed error information. For example, the following sample illustrates a possible technique for reporting errors that occur during synchronization:
public void Sync() { try { _conn.Synchronize( this ); _inSync = false; } catch( ULException uEx ){ if( uEx.NativeError == ULSQLCode.SQLE_COMMUNICATIONS_ERROR ) { MessageBox.Show( "StreamErrorCode = " + _conn.SyncResult.StreamErrorCode.ToString() + "\r\n" + "StreamErrorContext = " + _conn.SyncResult.StreamErrorContext + "\r\n" + "StreamErrorID = " + _conn.SyncResult.StreamErrorID + "\r\n" + "StreamErrorSystem = " + _conn.SyncResult.StreamErrorSystem + "\r\n" ); } else { MessageBox.Show(uEx.Message); } } catch(System.Exception ex ) { MessageBox.Show(ex.Message); } } |
See:
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |