private static VirtuosoErrorCollection CreateErrors(CLI.ReturnCode rc) { string message = null; switch (rc) { case CLI.ReturnCode.SQL_INVALID_HANDLE: message = "Invalid Handle"; break; case CLI.ReturnCode.SQL_NEED_DATA: message = "Need Data"; break; case CLI.ReturnCode.SQL_STILL_EXECUTING: message = "Still Executing"; break; default: message = "Unexpected Return Code"; break; } VirtuosoErrorCollection errors = new VirtuosoErrorCollection(); VirtuosoError error = new VirtuosoError(message, ""); errors.Add(error); return(errors); }
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); }
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; }
private static VirtuosoErrorCollection CreateErrors (CLI.ReturnCode rc) { string message = null; switch (rc) { case CLI.ReturnCode.SQL_INVALID_HANDLE: message = "Invalid Handle"; break; case CLI.ReturnCode.SQL_NEED_DATA: message = "Need Data"; break; case CLI.ReturnCode.SQL_STILL_EXECUTING: message = "Still Executing"; break; default: message = "Unexpected Return Code"; break; } VirtuosoErrorCollection errors = new VirtuosoErrorCollection (); VirtuosoError error = new VirtuosoError (message, ""); errors.Add (error); return errors; }