2010-07-25 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[mono.git] / mcs / class / System.Data / System.Data.OleDb.jvm / OleDbException.cs
1 //\r
2 // System.Data.OleDb.OleDbException\r
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 //
10
11 //
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.
30 //\r
31 \r
32 \r
33 \r
34 namespace System.Data.OleDb\r
35 {\r
36 \r
37     using java.sql;\r
38         using System.Text;\r
39         using System.Data.Common;\r
40         using System.Data.ProviderBase;\r
41 \r
42     /*\r
43     * CURRENT LIMITATIONS\r
44     * 1. Constructor for serialization SqlException(SerializationInfo info, StreamingContext sc) \r
45     *    is not supported.\r
46     * 2. Method "void GetObjectData(...,...)" is not supported (serialization)\r
47     */\r
48 #if NET_2_0\r
49         public sealed class OleDbException : AbstractDbException\r
50         {\r
51                 internal OleDbException (Exception cause, OleDbConnection connection) : base (cause, connection) { }\r
52 \r
53                 internal OleDbException (SQLException cause, OleDbConnection connection) : base (cause, connection) { }\r
54 \r
55                 internal OleDbException (string message, SQLException cause, OleDbConnection connection) : base (message, cause, connection) { }\r
56 \r
57                 protected override AbstractDbErrorCollection DbErrors {\r
58                         get {\r
59                                 return Errors;\r
60                         }\r
61                 }\r
62 \r
63                 public OleDbErrorCollection Errors {\r
64                         get {\r
65                                 return new OleDbErrorCollection (_cause, _connection);\r
66                         }\r
67                 }\r
68 \r
69                 public override int ErrorCode {\r
70                         get {\r
71                                 return DbErrorCode;\r
72                         }\r
73                 }\r
74         }\r
75 #else\r
76     public sealed class OleDbException :  System.Runtime.InteropServices.ExternalException\r
77     {\r
78                 private class OleDbExceptionImpl : AbstractDbException {\r
79                         internal OleDbExceptionImpl(Exception cause, OleDbConnection connection) : base(cause, connection) {}\r
80 \r
81                         internal OleDbExceptionImpl(SQLException cause, OleDbConnection connection) : base(cause, connection) {}\r
82 \r
83                         internal OleDbExceptionImpl(string message, SQLException cause, OleDbConnection connection) : base(message, cause, connection) {}\r
84 \r
85                         protected override AbstractDbErrorCollection DbErrors {\r
86                                 get {\r
87                                         return Errors;\r
88                                 }\r
89                         }\r
90 \r
91                         public OleDbErrorCollection Errors {\r
92                                 get {\r
93                                         return new OleDbErrorCollection(_cause, _connection);\r
94                                 }\r
95                         }\r
96 \r
97                         public int ErrorCode {\r
98                                 get {\r
99                                         return DbErrorCode;\r
100                                 }\r
101                         }\r
102                 }\r
103                 \r
104                 OleDbExceptionImpl _impl;\r
105 \r
106                 internal OleDbException(Exception cause, OleDbConnection connection) : base(null, cause) {\r
107                         _impl = new OleDbExceptionImpl(cause, connection);\r
108                 }\r
109 \r
110                 internal OleDbException(SQLException cause, OleDbConnection connection) : base(null, cause) {\r
111                         _impl = new OleDbExceptionImpl(cause, connection);\r
112                 }\r
113 \r
114                 internal OleDbException(string message, SQLException cause, OleDbConnection connection) : base(null, cause) {\r
115                         _impl = new OleDbExceptionImpl(message, cause, connection);\r
116                 }\r
117         /**\r
118          * Gets a collection of one or more SqlError objects that give detailed \r
119          * information about exceptions generated by the SQL Server .NET Data Provider.\r
120          * @return collection of SqlError objects\r
121          */\r
122         public OleDbErrorCollection Errors\r
123         {\r
124             get\r
125             {\r
126                                 return (OleDbErrorCollection)_impl.Errors;\r
127             }\r
128         }\r
129 \r
130         /**\r
131          * Gets the error code of the error.\r
132          * @return The error code of the error.\r
133          */\r
134         public override int ErrorCode\r
135         {\r
136             get\r
137             {\r
138                 return base.HResult;\r
139             }\r
140         }\r
141 \r
142  \r
143         /**\r
144          * Gets the name of the OLE DB provider that generated the error.\r
145          * @return the name of the OLE DB provider that generated the error. \r
146          */\r
147         public override String Source\r
148         {\r
149             get\r
150             {\r
151                 return _impl.Source;\r
152             }\r
153         }\r
154 \r
155                 public override string Message {\r
156                         get {\r
157                                 return _impl.Message;\r
158                         }\r
159                 }\r
160 \r
161     }\r
162 #endif\r
163 }