[Cleanup] Removed JavaEE csproj and sln files
[mono-project.git] / mcs / class / System.Data / System.Data.SqlClient.jvm / SqlException.cs
bloba197c3fd926ad8d0bfa6873e7c7149c1c4c625aa
1 //
2 // System.Data.SqlClient.SqlException
3 //
4 // Authors:
5 // Konstantin Triger <kostat@mainsoft.com>
6 // Boris Kirzner <borisk@mainsoft.com>
7 //
8 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
9 //
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:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
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
35 using java.sql;
37 using System;
38 using System.Data.ProviderBase;
40 /**
41 * The exception that is thrown when SQL Server returns a warning or error.
42 * This class cannot be inherited.
46 * CURRENT LIMITATIONS
47 * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc)
48 * is not supported.
49 * 2. Method "void GetObjectData(...,...)" is not supported (serialization)
52 public sealed class SqlException : AbstractDbException
54 internal SqlException(Exception cause, SqlConnection connection) : base(cause, connection) {}
56 internal SqlException(SQLException cause, SqlConnection connection) : base(cause, connection) {}
58 internal SqlException(string message, SQLException cause, SqlConnection connection) : base(message, cause, connection) {}
60 protected override AbstractDbErrorCollection DbErrors {
61 get {
62 return Errors;
68 /**
69 * Gets the severity level of the error returned from the SQL Server .NET
70 * Data Provider.
71 * @return severity level of the first error in the collection.
73 public byte Class
75 get
77 SqlErrorCollection errors = Errors;
78 return errors.Count > 0 ? errors[0].Class : (byte)0;
82 /**
83 * Gets a collection of one or more SqlError objects that give detailed
84 * information about exceptions generated by the SQL Server .NET Data Provider.
85 * @return collection of SqlError objects
87 public SqlErrorCollection Errors
89 get
91 return new SqlErrorCollection(_cause, _connection);
95 /**
96 * Gets the line number within the Transact-SQL command batch or stored
97 * procedure that generated the error.
98 * @return line number of the first error in the collection.
100 public int LineNumber
104 SqlErrorCollection errors = Errors;
105 return errors.Count > 0 ? errors[0].LineNumber : 0;
110 * Gets a number that identifies the type of error.
111 * @return number that identifies the type of first error in the collection
113 public int Number
117 SqlErrorCollection errors = Errors;
118 return errors.Count > 0 ? errors[0].Number : 0;
123 * Gets the name of the stored procedure or remote procedure call (RPC)
124 * that generated the error.
125 * @return name of the stored procedure
127 public String Procedure
131 SqlErrorCollection errors = Errors;
132 return errors.Count > 0 ? errors[0].Procedure : null;
137 * Gets the name of the computer running an instance of SQL Server
138 * that generated the error.
139 * @return name of the computer where error generated
141 public String Server
145 SqlErrorCollection errors = Errors;
146 return errors.Count > 0 ? errors[0].Server : null;
152 * Gets a numeric error code from SQL Server that represents an error,
153 * warning or "no data found" message.
154 * @return numeric error code from SQL Server
156 public byte State
160 SqlErrorCollection errors = Errors;
161 return errors.Count > 0 ? errors[0].State : (byte)0;