Implemented respective AddWithValue methods
[mono.git] / mcs / class / System.Data / System.Data.SqlClient.jvm / SqlError.cs
1 //\r
2 // System.Data.SqlClient.SqlError\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 //
31
32 namespace System.Data.SqlClient
33 {
34         using System.Data.ProviderBase;
35         using java.sql;
36         using System.Data.Common;
37
38     /**
39      * Collects information relevant to a warning or error returned by SQL Server.
40      */
41
42         [Serializable]
43     public class SqlError : AbstractDbError
44     {
45                 string _serverVersion;
46         /**
47          * Initialize SqlError object
48          * */
49         internal SqlError(SQLException e, AbstractDBConnection connection) : base(e, connection)
50         {
51                         if (connection != null)
52                                 _serverVersion = connection.ServerVersion;
53         }
54
55         /**
56          * Overridden. Gets the complete text of the error message.
57          *
58          * @return A string representation of the current object.
59          */
60         public override String ToString()
61         {
62             return String.Concat("SqlError:", Message, _e.StackTrace);
63         }
64
65         /**
66          * Gets the name of the provider that generated the error.
67          *
68          * @return The name of the provider
69          */
70         public String Source
71         {
72             get
73             {
74                 return DbSource;
75             }
76         }
77
78         /**
79          * Gets a number that identifies the type of error.
80          *
81          * @return Number of the error
82          */
83         public int Number
84         {
85             get
86             {
87                 return DbErrorCode;
88             }
89         }
90
91         /**
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.
95          *
96          * @return Error Code
97          */
98         public byte State
99         {
100             get
101             {
102                 return 0; // & BitConstants.ALL_BYTE;
103             }
104         }
105
106         /**
107          * Gets the severity level of the error returned from SQL Server.
108          *
109          * @return Severity level of the error
110          */
111         public byte Class
112         {
113             get
114             {
115                 return 0; // & BitConstants.ALL_BYTE;
116             }
117         }
118
119         /**
120          * Gets the name of the instance of SQL Server that generated the error.
121          *
122          * @return The name of the server
123          */
124         public String Server
125         {
126             get
127             {
128                 return _serverVersion;
129             }
130         }
131
132         /**
133          * Gets the text describing the error.
134          *
135          * @return The text describing the error
136          */
137         public String Message
138         {
139             get
140             {
141                 return DbMessage;
142             }
143         }
144
145         /**
146          * Gets the name of the stored procedure or remote procedure call (RPC)
147          * that generated the error.
148          *
149          * @return The name of stored procedure that generated the error.
150          */
151         public String Procedure
152         {
153             get
154             {
155                 return null;
156             }
157         }
158
159         /**
160          * Bets the line number within the Transact-SQL command batch or stored
161          * procedure that contains the error.
162          *
163          * @return Line number of error in stored procedure
164          */
165         public int LineNumber
166         {
167             get
168             {
169                 return 0;
170             }
171         }
172     }
173 }