OleDbException.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //
  2. // System.Data.OleDb.OleDbException
  3. //
  4. // Authors:
  5. // Konstantin Triger <[email protected]>
  6. // Boris Kirzner <[email protected]>
  7. //
  8. // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. namespace System.Data.OleDb
  31. {
  32. using java.sql;
  33. using System.Text;
  34. using System.Data.Common;
  35. using System.Data.ProviderBase;
  36. /*
  37. * CURRENT LIMITATIONS
  38. * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc)
  39. * is not supported.
  40. * 2. Method "void GetObjectData(...,...)" is not supported (serialization)
  41. */
  42. public sealed class OleDbException : System.Runtime.InteropServices.ExternalException
  43. {
  44. private class OleDbExceptionImpl : AbstractDbException {
  45. internal OleDbExceptionImpl(Exception cause, OleDbConnection connection) : base(cause, connection) {}
  46. internal OleDbExceptionImpl(SQLException cause, OleDbConnection connection) : base(cause, connection) {}
  47. internal OleDbExceptionImpl(string message, SQLException cause, OleDbConnection connection) : base(message, cause, connection) {}
  48. protected override AbstractDbErrorCollection DbErrors {
  49. get {
  50. return Errors;
  51. }
  52. }
  53. public OleDbErrorCollection Errors {
  54. get {
  55. return new OleDbErrorCollection(_cause, _connection);
  56. }
  57. }
  58. public int ErrorCode {
  59. get {
  60. return DbErrorCode;
  61. }
  62. }
  63. }
  64. OleDbExceptionImpl _impl;
  65. internal OleDbException(Exception cause, OleDbConnection connection) : base(null, cause) {
  66. _impl = new OleDbExceptionImpl(cause, connection);
  67. }
  68. internal OleDbException(SQLException cause, OleDbConnection connection) : base(null, cause) {
  69. _impl = new OleDbExceptionImpl(cause, connection);
  70. }
  71. internal OleDbException(string message, SQLException cause, OleDbConnection connection) : base(null, cause) {
  72. _impl = new OleDbExceptionImpl(message, cause, connection);
  73. }
  74. /**
  75. * Gets a collection of one or more SqlError objects that give detailed
  76. * information about exceptions generated by the SQL Server .NET Data Provider.
  77. * @return collection of SqlError objects
  78. */
  79. public OleDbErrorCollection Errors
  80. {
  81. get
  82. {
  83. return (OleDbErrorCollection)_impl.Errors;
  84. }
  85. }
  86. /**
  87. * Gets the error code of the error.
  88. * @return The error code of the error.
  89. */
  90. public override int ErrorCode
  91. {
  92. get
  93. {
  94. return base.HResult;
  95. }
  96. }
  97. /**
  98. * Gets the name of the OLE DB provider that generated the error.
  99. * @return the name of the OLE DB provider that generated the error.
  100. */
  101. public override String Source
  102. {
  103. get
  104. {
  105. return _impl.Source;
  106. }
  107. }
  108. public override string Message {
  109. get {
  110. return _impl.Message;
  111. }
  112. }
  113. }
  114. }