SqlError.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * @(#)SqlError.java 1.0 01/01/03
  3. *
  4. * Copyright 2002 Mainsoft Corporation. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Mainsoft Corporation.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. namespace System.Data.SqlClient
  11. {
  12. using System.Data.ProviderBase;
  13. using java.sql;
  14. using System.Data.Common;
  15. /**
  16. * Collects information relevant to a warning or error returned by SQL Server.
  17. *
  18. * @author Pavel Sandler
  19. * @version 1.0, 01/01/03
  20. */
  21. [Serializable]
  22. public class SqlError : AbstractDbError
  23. {
  24. string _serverVersion;
  25. /**
  26. * Initialize SqlError object
  27. * */
  28. internal SqlError(SQLException e, AbstractDBConnection connection) : base(e, connection)
  29. {
  30. if (connection != null)
  31. _serverVersion = connection.ServerVersion;
  32. }
  33. /**
  34. * Overridden. Gets the complete text of the error message.
  35. *
  36. * @return A string representation of the current object.
  37. */
  38. public override String ToString()
  39. {
  40. return String.Concat("SqlError:", Message, _e.StackTrace);
  41. }
  42. /**
  43. * Gets the name of the provider that generated the error.
  44. *
  45. * @return The name of the provider
  46. */
  47. public String Source
  48. {
  49. get
  50. {
  51. return DbSource;
  52. }
  53. }
  54. /**
  55. * Gets a number that identifies the type of error.
  56. *
  57. * @return Number of the error
  58. */
  59. public int Number
  60. {
  61. get
  62. {
  63. return DbErrorCode;
  64. }
  65. }
  66. /**
  67. * Gets a numeric error code from SQL Server that represents an error,
  68. * warning or "no data found" message. For more information on how to
  69. * decode these values, see SQL Server Books Online.
  70. *
  71. * @return Error Code
  72. */
  73. public byte State
  74. {
  75. get
  76. {
  77. return 0; // & BitConstants.ALL_BYTE;
  78. }
  79. }
  80. /**
  81. * Gets the severity level of the error returned from SQL Server.
  82. *
  83. * @return Severity level of the error
  84. */
  85. public byte Class
  86. {
  87. get
  88. {
  89. return 0; // & BitConstants.ALL_BYTE;
  90. }
  91. }
  92. /**
  93. * Gets the name of the instance of SQL Server that generated the error.
  94. *
  95. * @return The name of the server
  96. */
  97. public String Server
  98. {
  99. get
  100. {
  101. return _serverVersion;
  102. }
  103. }
  104. /**
  105. * Gets the text describing the error.
  106. *
  107. * @return The text describing the error
  108. */
  109. public String Message
  110. {
  111. get
  112. {
  113. return DbMessage;
  114. }
  115. }
  116. /**
  117. * Gets the name of the stored procedure or remote procedure call (RPC)
  118. * that generated the error.
  119. *
  120. * @return The name of stored procedure that generated the error.
  121. */
  122. public String Procedure
  123. {
  124. get
  125. {
  126. return null;
  127. }
  128. }
  129. /**
  130. * Bets the line number within the Transact-SQL command batch or stored
  131. * procedure that contains the error.
  132. *
  133. * @return Line number of error in stored procedure
  134. */
  135. public int LineNumber
  136. {
  137. get
  138. {
  139. return 0;
  140. }
  141. }
  142. }
  143. }