// deprecated internal static void HandleWarnings( CLI.HandleType handleType, IntPtr handle, VirtuosoConnection connection) { VirtuosoInfoMessageEventArgs args = new VirtuosoInfoMessageEventArgs(OdbcErrors.CreateErrors(handleType, handle)); connection.OnInfoMessage(args); }
internal static VirtuosoErrorCollection CreateErrors(CLI.HandleType handleType, IntPtr handle) { VirtuosoErrorCollection errors = new VirtuosoErrorCollection(); MemoryHandle sqlState = null; MemoryHandle messageText = null; try { sqlState = new MemoryHandle((CLI.SQL_SQLSTATE_SIZE + 1) * Platform.WideCharSize); messageText = new MemoryHandle((CLI.SQL_MAX_MESSAGE_LEN + 1) * Platform.WideCharSize); for (short recNumber = 1; ; recNumber++) { int nativeError; short textLength; CLI.ReturnCode rc = (CLI.ReturnCode)CLI.SQLGetDiagRec( (short)handleType, handle, recNumber, sqlState.Handle, out nativeError, messageText.Handle, (short)(messageText.Length / Platform.WideCharSize), out textLength); if (rc != CLI.ReturnCode.SQL_SUCCESS && rc != CLI.ReturnCode.SQL_SUCCESS_WITH_INFO) { break; } #if false //System.Console.WriteLine ("length: {0}", textLength); string sMessageText = Platform.WideCharsToString(messageText.Handle, textLength); string sSqlState = Platform.WideCharsToString(sqlState.Handle, CLI.SQL_SQLSTATE_SIZE); #else string sMessageText = Marshal.PtrToStringAnsi(messageText.Handle, textLength); string sSqlState = Marshal.PtrToStringAnsi(sqlState.Handle, CLI.SQL_SQLSTATE_SIZE); #endif VirtuosoError error = new VirtuosoError(sMessageText, sSqlState); errors.Add(error); } } finally { if (sqlState != null) { sqlState.Dispose(); } if (messageText != null) { messageText.Dispose(); } } return(errors); }
// deprecated internal static void HandleResult( CLI.ReturnCode returnCode, CLI.HandleType handleType, IntPtr handle, VirtuosoConnection connection) { if (returnCode == CLI.ReturnCode.SQL_SUCCESS_WITH_INFO) { HandleWarnings(handleType, handle, connection); } else if (returnCode != CLI.ReturnCode.SQL_SUCCESS) { HandleErrors(returnCode, handleType, handle); } }
// deprecated internal static void HandleErrors( CLI.ReturnCode returnCode, CLI.HandleType handleType, IntPtr handle) { VirtuosoErrorCollection errors = null; if (returnCode == CLI.ReturnCode.SQL_ERROR) { errors = OdbcErrors.CreateErrors(handleType, handle); } else { errors = CreateErrors(returnCode); } throw new VirtuosoException(returnCode, errors); }