Files
mono/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs
T
Tim Coleman fcf980c6cf 2002-11-04 Tim Coleman <[email protected]>
* list:
                Add Mono.Data.TdsClient.Internal.TdsInternalError
                Add Mono.Data.TdsClient.Internal.TdsInternalErrorCollection
                Add Mono.Data.TdsClient.Internal.TdsInternalErrorMessageEventHandler
                Add Mono.Data.TdsClient.Internal.TdsInternalErrorMessageEventArgs
                Add Mono.Data.TdsClient.Internal.TdsInternalInfoMessageEventHandler
                Add Mono.Data.TdsClient.Internal.TdsInternalInfoMessageEventArgs
                Remove Mono.Data.TdsClient.Internal.TdsPacketErrorResult
                Remove Mono.Data.TdsClient.Internal.TdsPacketErrorResultCollection
                Remove Mono.Data.TdsClient.Internal.TdsPacketMessageResult
        * System.Data.Common/RowUpdatedEventArgs.cs:
        * System.Data.Common/RowUpdatingEventArgs.cs:
                Implement
        * System.Data.SqlClient/SqlCommand.cs:
        * System.Data.SqlClient/SqlDataReader.cs:
        * System.Data.SqlClient/SqlTransaction.cs:
                Remove checks for errors.  These are now handled by events
        * System.Data.SqlClient/SqlConnection.cs:
        * System.Data.SqlClient/SqlError.cs:
        * System.Data.SqlClient/SqlException.cs:
        * System.Data.SqlClient/SqlInfoMessageEventArgs.cs:
                Add event handlers and triggers for errors, messages, state change
        * System.Data.SqlClient/SqlParameter.cs:
                Re-add refreshproperties
        * System.Data.SqlClient/SqlRowUpdatedEventArgs.cs:
        * System.Data.SqlClient/SqlRowUpdatedEventHandler.cs:
        * System.Data.SqlClient/SqlRowUpdatingEventArgs.cs:
        * System.Data.SqlClient/SqlRowUpdatingEventHandler.cs:
                Implement

svn path=/trunk/mcs/; revision=8825
2002-11-05 04:27:25 +00:00

153 lines
2.9 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.TdsClient.Internal;
using System;
using System.ComponentModel;
using System.Data;
using System.Runtime.Serialization;
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
[MonoTODO]
public byte Class {
get {
if(errors.Count == 0)
return 0; // FIXME: throw exception here?
else
return errors[0].Class;
}
}
[MonoTODO]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
public SqlErrorCollection Errors {
get { return errors; }
}
[MonoTODO]
public int LineNumber {
get { if(errors.Count == 0)
return 0; // FIXME: throw exception here?
return errors[0].LineNumber;
}
}
[MonoTODO]
public override string Message {
get {
if(errors.Count == 0)
return ""; // FIXME: throw exception?
else {
String msg = "";
int i = 0;
for(i = 0; i < errors.Count - 1; i++) {
msg = msg + errors[i].Message + "\n";
}
msg = msg + errors[i].Message;
return msg;
}
}
}
[MonoTODO]
public int Number {
get {
if(errors.Count == 0)
return 0; // FIXME: throw exception?
else
return errors[0].Number;
}
}
[MonoTODO]
public string Procedure {
get {
if(errors.Count == 0)
return ""; // FIXME: throw exception?
else
return errors[0].Procedure;
}
}
[MonoTODO]
public string Server {
get {
if(errors.Count == 0)
return ""; // FIXME: throw exception?
else
return errors[0].Server;
}
}
[MonoTODO]
public override string Source {
get {
if(errors.Count == 0)
return ""; // FIXME: throw exception?
else
return errors[0].Source;
}
}
[MonoTODO]
public byte State {
get {
if(errors.Count == 0)
return 0; // FIXME: throw exception?
else
return errors[0].State;
}
}
#endregion // Properties
#region Methods
[MonoTODO]
public override void GetObjectData (SerializationInfo si, StreamingContext context)
{
throw new NotImplementedException ();
}
#endregion // Methods
}
}