2 // System.Data.SqlClient.SqlError
\r
5 // Konstantin Triger <kostat@mainsoft.com>
6 // Boris Kirzner <borisk@mainsoft.com>
8 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 namespace System.Data.SqlClient
34 using System.Data.ProviderBase;
36 using System.Data.Common;
39 * Collects information relevant to a warning or error returned by SQL Server.
43 public class SqlError : AbstractDbError
45 string _serverVersion;
47 * Initialize SqlError object
49 internal SqlError(SQLException e, AbstractDBConnection connection) : base(e, connection)
51 if (connection != null)
52 _serverVersion = connection.ServerVersion;
56 * Overridden. Gets the complete text of the error message.
58 * @return A string representation of the current object.
60 public override String ToString()
62 return String.Concat("SqlError:", Message, _e.StackTrace);
66 * Gets the name of the provider that generated the error.
68 * @return The name of the provider
79 * Gets a number that identifies the type of error.
81 * @return Number of the error
92 * Gets a numeric error code from SQL Server that represents an error,
93 * warning or "no data found" message. For more information on how to
94 * decode these values, see SQL Server Books Online.
102 return 0; // & BitConstants.ALL_BYTE;
107 * Gets the severity level of the error returned from SQL Server.
109 * @return Severity level of the error
115 return 0; // & BitConstants.ALL_BYTE;
120 * Gets the name of the instance of SQL Server that generated the error.
122 * @return The name of the server
128 return _serverVersion;
133 * Gets the text describing the error.
135 * @return The text describing the error
137 public String Message
146 * Gets the name of the stored procedure or remote procedure call (RPC)
147 * that generated the error.
149 * @return The name of stored procedure that generated the error.
151 public String Procedure
160 * Bets the line number within the Transact-SQL command batch or stored
161 * procedure that contains the error.
163 * @return Line number of error in stored procedure
165 public int LineNumber