Files
mono/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
T
Tim Coleman 50793b9078 2002-11-21 Tim Coleman <[email protected]>
* System.Data.build:
        * System.Data.SqlClient/SqlCommand.cs:
        * System.Data.SqlClient/SqlConnection.cs:
        * System.Data.SqlClient/SqlConnectionPool.cs:
        * System.Data.SqlClient/SqlDataReader.cs:
        * System.Data.SqlClient/SqlException.cs:
        * System.Data.SqlClient/SqlInfoMessageEventArgs.cs:
        * System.Data.SqlClient/SqlParameter.cs:
        * System.Data.SqlClient/SqlTransaction.cs:
        * System.Data.SqlClient/SqlXmlTextReader.cs:
        * System.Data.SqlTypes/SqlDecimal.cs:
                Modify to accept new Mono.Data.Tds.Protocol
                namespace in Mono.Data.Tds assembly, replacing
                Mono.Data.TdsClient.Internal

svn path=/trunk/mcs/; revision=9131
2002-11-21 16:55:20 +00:00

111 lines
2.4 KiB
C#

//
// System.Data.SqlClient.SqlException.cs
//
// Author:
// Rodrigo Moya ([email protected])
// Daniel Morgan ([email protected])
// Tim Coleman ([email protected])
//
// (C) Ximian, Inc
// Copyright (C) Tim Coleman, 2002
//
using Mono.Data.Tds.Protocol;
using System;
using System.ComponentModel;
using System.Data;
using System.Runtime.Serialization;
using System.Text;
namespace System.Data.SqlClient {
[Serializable]
public sealed class SqlException : SystemException
{
#region Fields
SqlErrorCollection errors;
#endregion // Fields
#region Constructors
internal SqlException ()
: base ("a SQL Exception has occurred.")
{
errors = new SqlErrorCollection();
}
internal SqlException (byte theClass, int lineNumber, string message, int number, string procedure, string server, string source, byte state)
: base (message)
{
errors = new SqlErrorCollection (theClass, lineNumber, message, number, procedure, server, source, state);
}
#endregion // Constructors
#region Properties
public byte Class {
get { return Errors [0].Class; }
}
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
public SqlErrorCollection Errors {
get { return errors; }
}
public int LineNumber {
get { return Errors [0].LineNumber; }
}
public override string Message {
get {
StringBuilder result = new StringBuilder ();
foreach (SqlError error in Errors) {
if (result.Length > 0)
result.Append ('\n');
result.Append (error.Message);
}
return result.ToString ();
}
}
public int Number {
get { return Errors [0].Number; }
}
public string Procedure {
get { return Errors [0].Procedure; }
}
public string Server {
get { return Errors [0].Server; }
}
public override string Source {
get { return Errors [0].Source; }
}
public byte State {
get { return Errors [0].State; }
}
#endregion // Properties
#region Methods
internal static SqlException FromTdsInternalException (TdsInternalException e)
{
return new SqlException (e.Class, e.LineNumber, e.Message, e.Number, e.Procedure, e.Server, "Mono SqlClient Data Provider", e.State);
}
[MonoTODO ("Determine how to serialize this class.")]
public override void GetObjectData (SerializationInfo si, StreamingContext context)
{
throw new NotImplementedException ();
}
#endregion // Methods
}
}