diff options
author | Tim Coleman <tim@mono-cvs.ximian.com> | 2002-11-05 07:27:25 +0300 |
---|---|---|
committer | Tim Coleman <tim@mono-cvs.ximian.com> | 2002-11-05 07:27:25 +0300 |
commit | fcf980c6cf262a9b8dc7fe51a9a3212d2db2bc1f (patch) | |
tree | 02fd4c3f36182c8a3bd3ea5c760fa13228c249f8 /mcs | |
parent | e6d0053af39c716ab05c344a871146ba41cf60ee (diff) |
2002-11-04 Tim Coleman <tim@timcoleman.com>
* 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
Diffstat (limited to 'mcs')
15 files changed, 271 insertions, 163 deletions
diff --git a/mcs/class/System.Data/ChangeLog b/mcs/class/System.Data/ChangeLog index 3f4ff8a8718..194503b7ff2 100644 --- a/mcs/class/System.Data/ChangeLog +++ b/mcs/class/System.Data/ChangeLog @@ -1,5 +1,35 @@ 2002-11-04 Tim Coleman <tim@timcoleman.com> * 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: + 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 + +2002-11-04 Tim Coleman <tim@timcoleman.com> + * list: Add Mono.Data.TdsClient.Internal.TdsBigDecimal Add System.Data.SqlClient.SqlParameterConverter Add System.Data.DataSysDescriptionAttribute diff --git a/mcs/class/System.Data/System.Data.Common/RowUpdatedEventArgs.cs b/mcs/class/System.Data/System.Data.Common/RowUpdatedEventArgs.cs index ab3aebe4451..53a121617ba 100644 --- a/mcs/class/System.Data/System.Data.Common/RowUpdatedEventArgs.cs +++ b/mcs/class/System.Data/System.Data.Common/RowUpdatedEventArgs.cs @@ -3,62 +3,84 @@ // // Author: // Rodrigo Moya (rodrigo@ximian.com) +// Tim Coleman (tim@timcoleman.com) // // (C) Ximian, Inc +// Copyright (C) Tim Coleman, 2002 // using System.Data; -namespace System.Data.Common -{ - /// <summary> - /// Provides data for the RowUpdated event of a .NET data provider. - /// </summary> +namespace System.Data.Common { public abstract class RowUpdatedEventArgs : EventArgs { + #region Fields + + DataRow dataRow; + IDbCommand command; + StatementType statementType; + DataTableMapping tableMapping; + Exception errors; + UpdateStatus status; + int recordsAffected; + + #endregion // Fields + + #region Constructors + [MonoTODO] - protected RowUpdatedEventArgs(DataRow dataRow, - IDbCommand command, - StatementType statementType, - DataTableMapping tableMapping) { - throw new NotImplementedException (); + protected RowUpdatedEventArgs (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) + { + this.dataRow = dataRow; + this.command = command; + this.statementType = statementType; + this.tableMapping = tableMapping; + this.errors = null; + this.status = UpdateStatus.Continue; + this.recordsAffected = 0; // FIXME } + + #endregion // Constructors + + #region Properties [MonoTODO] public IDbCommand Command { - get { throw new NotImplementedException (); } + get { return command; } } [MonoTODO] public Exception Errors { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + get { return errors; } + set { errors = value; } } [MonoTODO] public int RecordsAffected { - get { throw new NotImplementedException (); } + get { return recordsAffected; } } [MonoTODO] public DataRow Row { - get { throw new NotImplementedException (); } + get { return dataRow; } } [MonoTODO] public StatementType StatementType { - get { throw new NotImplementedException (); } + get { return statementType; } } [MonoTODO] public UpdateStatus Status { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + get { return status; } + set { status = value; } } [MonoTODO] public DataTableMapping TableMapping { - get { throw new NotImplementedException (); } + get { return tableMapping; } } + + #endregion // Properties } } diff --git a/mcs/class/System.Data/System.Data.Common/RowUpdatingEventArgs.cs b/mcs/class/System.Data/System.Data.Common/RowUpdatingEventArgs.cs index 6d5eae65d84..d84e6a7b9bb 100644 --- a/mcs/class/System.Data/System.Data.Common/RowUpdatingEventArgs.cs +++ b/mcs/class/System.Data/System.Data.Common/RowUpdatingEventArgs.cs @@ -3,56 +3,69 @@ // // Author: // Rodrigo Moya (rodrigo@ximian.com) +// Tim Coleman (tim@timcoleman.com) // // (C) Ximian, Inc +// Copyright (C) Tim Coleman, 2002 // -namespace System.Data.Common -{ - /// <summary> - /// Provides the data for the RowUpdating event of a .NET data provider. - /// </summary> +namespace System.Data.Common { public abstract class RowUpdatingEventArgs : EventArgs { - [MonoTODO] - protected RowUpdatingEventArgs(DataRow dataRow, - IDbCommand command, - StatementType statementType, - DataTableMapping tableMapping) { - throw new NotImplementedException (); + #region Fields + + DataRow dataRow; + IDbCommand command; + StatementType statementType; + DataTableMapping tableMapping; + UpdateStatus status; + Exception errors; + + #endregion // Fields + + #region Constructors + + protected RowUpdatingEventArgs (DataRow dataRow, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) + { + this.dataRow = dataRow; + this.command = command; + this.statementType = statementType; + this.tableMapping = tableMapping; + this.status = UpdateStatus.Continue; + this.errors = null; } + + #endregion // Constructors + + #region Properties - [MonoTODO] public IDbCommand Command { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + get { return command; } + set { command = value; } } - [MonoTODO] public Exception Errors { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + get { return errors; } + set { errors = value; } } - [MonoTODO] public DataRow Row { - get { throw new NotImplementedException (); } + get { return dataRow; } } - [MonoTODO] public StatementType StatementType { - get { throw new NotImplementedException (); } + get { return statementType; } } - [MonoTODO] public UpdateStatus Status { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + get { return status; } + set { status = value; } } - [MonoTODO] public DataTableMapping TableMapping { - get { throw new NotImplementedException (); } + get { return tableMapping; } } + + #endregion // Properties } } diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs index bb20706ad44..08c873ec3ab 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlCommand.cs @@ -84,7 +84,7 @@ namespace System.Data.SqlClient { [DataSysDescription ("Command text to execute.")] [DefaultValue ("")] - //[RefreshProperties (RefreshProperties.All)] + [RefreshProperties (RefreshProperties.All)] public string CommandText { get { return CommandText; } set { commandText = value; } @@ -103,7 +103,7 @@ namespace System.Data.SqlClient { [DataSysDescription ("How to interpret the CommandText.")] [DefaultValue (CommandType.Text)] - //[RefreshProperties (RefreshProperties.All)] + [RefreshProperties (RefreshProperties.All)] public CommandType CommandType { get { return commandType; } set { commandType = value; } @@ -323,7 +323,6 @@ namespace System.Data.SqlClient { if (connection == null || connection.Tds == null) return; connection.Tds.Cancel (); - connection.CheckForErrors (); } internal void CloseDataReader (bool moreResults) @@ -344,7 +343,6 @@ namespace System.Data.SqlClient { { ValidateCommand ("ExecuteNonQuery"); int result = connection.Tds.ExecuteNonQuery (BuildCommand ()); - connection.CheckForErrors (); GetOutputParameters (); return result; } @@ -359,7 +357,6 @@ namespace System.Data.SqlClient { ValidateCommand ("ExecuteReader"); this.behavior = behavior; connection.Tds.ExecuteQuery (BuildCommand ()); - connection.CheckForErrors (); connection.DataReader = new SqlDataReader (this); return connection.DataReader; @@ -369,16 +366,13 @@ namespace System.Data.SqlClient { { ValidateCommand ("ExecuteScalar"); connection.Tds.ExecuteQuery (BuildCommand ()); - connection.CheckForErrors (); bool moreResults = connection.Tds.NextResult (); - connection.CheckForErrors (); if (!moreResults) return null; moreResults = connection.Tds.NextRow (); - connection.CheckForErrors (); if (!moreResults) return null; @@ -392,7 +386,6 @@ namespace System.Data.SqlClient { { ValidateCommand ("ExecuteXmlReader"); connection.Tds.ExecuteQuery (BuildCommand ()); - connection.CheckForErrors (); SqlDataReader dataReader = new SqlDataReader (this); SqlXmlTextReader textReader = new SqlXmlTextReader (dataReader); @@ -473,7 +466,6 @@ namespace System.Data.SqlClient { { ValidateCommand ("Prepare"); connection.Tds.ExecuteNonQuery (BuildPrepare ()); - connection.CheckForErrors (); if (connection.Tds.OutputParameters.Count == 0 || connection.Tds.OutputParameters[0] == null) throw new Exception ("Could not prepare the statement."); diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs index 139d742036c..a3ba8735a96 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlConnection.cs @@ -58,10 +58,12 @@ namespace System.Data.SqlClient { SqlDataReader dataReader = null; XmlReader xmlReader = null; - // The TDS object ITds tds; + static readonly object EventSqlInfoMessage = new object (); + static readonly object EventStateChange = new object (); + #endregion // Fields #region Constructors @@ -84,7 +86,7 @@ namespace System.Data.SqlClient { [DataSysDescription ("Information used to connect to a DataSource, such as 'Data Source=x;Initial Catalog=x;Integrated Security=SSPI'.")] [DefaultValue ("")] [RecommendedAsConfigurable (true)] - //[RefreshProperties (RefreshProperties.All)] + [RefreshProperties (RefreshProperties.All)] public string ConnectionString { get { return connectionString; } set { SetConnectionString (value); } @@ -154,6 +156,34 @@ namespace System.Data.SqlClient { #endregion // Properties + #region Events + + public event SqlInfoMessageEventHandler InfoMessage { + add { Events.AddHandler (EventSqlInfoMessage, value); } + remove { Events.RemoveHandler (EventSqlInfoMessage, value); } + } + + public event StateChangeEventHandler StateChange { + add { Events.AddHandler (EventStateChange, value); } + remove { Events.RemoveHandler (EventStateChange, value); } + } + + #endregion // Events + + #region Delegates + + private void ErrorHandler (object sender, TdsInternalErrorMessageEventArgs e) + { + throw new SqlException (e.Class, e.LineNumber, e.Message, e.Number, e.Procedure, e.Server, "Mono SqlClient Data Provider", e.State); + } + + private void MessageHandler (object sender, TdsInternalInfoMessageEventArgs e) + { + OnSqlInfoMessage (CreateSqlInfoMessageEvent (e.Errors)); + } + + #endregion // Delegates + #region Methods public SqlTransaction BeginTransaction () @@ -173,11 +203,12 @@ namespace System.Data.SqlClient { public SqlTransaction BeginTransaction (IsolationLevel iso, string transactionName) { + if (state == ConnectionState.Closed) + throw new InvalidOperationException ("The connection is not open."); if (transaction != null) throw new InvalidOperationException ("SqlConnection does not support parallel transactions."); tds.ExecuteNonQuery (String.Format ("BEGIN TRANSACTION {0}", transactionName)); - CheckForErrors (); transaction = new SqlTransaction (this, iso); return transaction; @@ -187,19 +218,17 @@ namespace System.Data.SqlClient { { if (!IsValidDatabaseName (database)) throw new ArgumentException (String.Format ("The database name {0} is not valid.")); - if (state != ConnectionState.Open) - throw new InvalidOperationException ("The connection is not open"); - + throw new InvalidOperationException ("The connection is not open."); tds.ExecuteNonQuery (String.Format ("use {0}", database)); - CheckForErrors (); } - internal void CheckForErrors () + private void ChangeState (ConnectionState currentState) { - if (tds.Errors.Count > 0) - throw SqlException.FromTdsError (tds.Errors); - } + ConnectionState originalState = state; + state = currentState; + OnStateChange (CreateStateChangeEvent (originalState, currentState)); + } public void Close () { @@ -209,7 +238,11 @@ namespace System.Data.SqlClient { pool.ReleaseConnection (tds); else tds.Disconnect (); - this.state = ConnectionState.Closed; + + tds.TdsErrorMessage -= new TdsInternalErrorMessageEventHandler (ErrorHandler); + tds.TdsInfoMessage -= new TdsInternalInfoMessageEventHandler (MessageHandler); + + ChangeState (ConnectionState.Closed); } public SqlCommand CreateCommand () @@ -218,6 +251,16 @@ namespace System.Data.SqlClient { command.Connection = this; return command; } + + private SqlInfoMessageEventArgs CreateSqlInfoMessageEvent (TdsInternalErrorCollection errors) + { + return new SqlInfoMessageEventArgs (errors); + } + + private StateChangeEventArgs CreateStateChangeEvent (ConnectionState originalState, ConnectionState currentState) + { + return new StateChangeEventArgs (originalState, currentState); + } protected override void Dispose (bool disposing) { @@ -260,6 +303,7 @@ namespace System.Data.SqlClient { { if (connectionString == null) throw new InvalidOperationException ("Connection string has not been initialized."); + if (!pooling) tds = new Tds70 (dataSource, port, packetSize); else { @@ -271,17 +315,15 @@ namespace System.Data.SqlClient { tds = pool.AllocateConnection (); } - state = ConnectionState.Open; + tds.TdsErrorMessage += new TdsInternalErrorMessageEventHandler (ErrorHandler); + tds.TdsInfoMessage += new TdsInternalInfoMessageEventHandler (MessageHandler); - if (!tds.IsConnected) { + if (!tds.IsConnected) tds.Connect (parms); - CheckForErrors (); - ChangeDatabase (parms.Database); - } - else if (connectionReset) { - tds.ExecuteNonQuery ("EXEC sp_connection_reset"); - CheckForErrors (); - } + else if (connectionReset) + tds.ExecuteNonQuery ("EXEC sp_reset_connection"); + + ChangeState (ConnectionState.Open); } void SetConnectionString (string connectionString) @@ -450,7 +492,6 @@ namespace System.Data.SqlClient { } } - static bool IsValidDatabaseName (string database) { if (database.Length > 32 || database.Length < 1) @@ -470,13 +511,21 @@ namespace System.Data.SqlClient { return true; } + private void OnSqlInfoMessage (SqlInfoMessageEventArgs value) + { + SqlInfoMessageEventHandler handler = (SqlInfoMessageEventHandler) Events [EventSqlInfoMessage]; + if (handler != null) + handler (this, value); + } + + private void OnStateChange (StateChangeEventArgs value) + { + StateChangeEventHandler handler = (StateChangeEventHandler) Events [EventStateChange]; + if (handler != null) + handler (this, value); + } + #endregion // Methods - #region Events - - public event SqlInfoMessageEventHandler InfoMessage; - public event StateChangeEventHandler StateChange; - - #endregion // Events } } diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs index 81b0ad82f1d..a6b2746a980 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlDataReader.cs @@ -641,7 +641,6 @@ namespace System.Data.SqlClient { schemaTable.Rows.Clear (); moreResults = command.Tds.NextResult (); - command.Connection.CheckForErrors (); rowsRead = 0; resultsRead += 1; return moreResults; @@ -657,7 +656,6 @@ namespace System.Data.SqlClient { return false; bool result = command.Tds.NextRow (); - command.Connection.CheckForErrors (); rowsRead += 1; diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlError.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlError.cs index 2fa37621be0..212cfe5c087 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlError.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlError.cs @@ -4,9 +4,12 @@ // Author: // Rodrigo Moya (rodrigo@ximian.com) // Daniel Morgan (danmorg@sc.rr.com) +// Tim Coleman (tim@timcoleman.com) // // (C) Ximian, Inc 2002 +// Copyright (C) Tim Coleman, 2002 // + using System; using System.Data; using System.Runtime.InteropServices; @@ -18,6 +21,8 @@ namespace System.Data.SqlClient { [Serializable] public sealed class SqlError { + #region Fields + byte theClass = 0; int lineNumber = 0; string message = ""; @@ -27,9 +32,12 @@ namespace System.Data.SqlClient { string source = ""; byte state = 0; - internal SqlError(byte theClass, int lineNumber, - string message, int number, string procedure, - string server, string source, byte state) { + #endregion // Fields + + #region Constructors + + internal SqlError (byte theClass, int lineNumber, string message, int number, string procedure, string server, string source, byte state) + { this.theClass = theClass; this.lineNumber = lineNumber; this.message = message; @@ -39,6 +47,8 @@ namespace System.Data.SqlClient { this.source = source; this.state = state; } + + #endregion // Constructors #region Properties @@ -47,58 +57,42 @@ namespace System.Data.SqlClient { /// severity level of the error /// </summary> public byte Class { - get { - return theClass; - } + get { return theClass; } } [MonoTODO] public int LineNumber { - get { - return lineNumber; - } + get { return lineNumber; } } [MonoTODO] public string Message { - get { - return message; - } + get { return message; } } [MonoTODO] public int Number { - get { - return number; - } + get { return number; } } [MonoTODO] public string Procedure { - get { - return procedure; - } + get { return procedure; } } [MonoTODO] public string Server { - get { - return server; - } + get { return server; } } [MonoTODO] public string Source { - get { - return source; - } + get { return source; } } [MonoTODO] public byte State { - get { - return state; - } + get { return state; } } #endregion @@ -116,35 +110,43 @@ namespace System.Data.SqlClient { return toStr; } - internal void SetClass(byte theClass) { + internal void SetClass (byte theClass) + { this.theClass = theClass; } - internal void SetLineNumber(int lineNumber) { + internal void SetLineNumber (int lineNumber) + { this.lineNumber = lineNumber; } - internal void SetMessage(string message) { + internal void SetMessage (string message) + { this.message = message; } - internal void SetNumber(int number) { + internal void SetNumber (int number) + { this.number = number; } - internal void SetProcedure(string procedure) { + internal void SetProcedure (string procedure) + { this.procedure = procedure; } - internal void SetServer(string server) { + internal void SetServer (string server) + { this.server = server; } - internal void SetSource(string source) { + internal void SetSource (string source) + { this.source = source; } - internal void SetState(byte state) { + internal void SetState (byte state) + { this.state = state; } diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs index 3cc2376ee9d..e885ef071bd 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlException.cs @@ -147,13 +147,6 @@ namespace System.Data.SqlClient { throw new NotImplementedException (); } - [MonoTODO] - internal static SqlException FromTdsError (TdsPacketErrorResultCollection errors) - { - TdsMessage message = errors[0].Message; - return new SqlException (message.Severity, message.Line, message.Message, message.Number, message.ProcName, message.Server, "Mono SqlClient Data Provider", message.State); - } - #endregion // Methods } } diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlInfoMessageEventArgs.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlInfoMessageEventArgs.cs index f1a5aebed1c..e31abfe7a8e 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlInfoMessageEventArgs.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlInfoMessageEventArgs.cs @@ -4,52 +4,56 @@ // Author: // Rodrigo Moya (rodrigo@ximian.com) // Daniel Morgan (danmorg@sc.rr.com) +// Tim Coleman (tim@timcoleman.com) // // (C) Ximian, Inc 2002 +// Copyright (C) Tim Coleman, 2002 // +using Mono.Data.TdsClient.Internal; using System; using System.Data; namespace System.Data.SqlClient { public sealed class SqlInfoMessageEventArgs : EventArgs { + #region Fields + + SqlErrorCollection errors = new SqlErrorCollection (); + + #endregion // Fields + #region Constructors - [MonoTODO] - internal SqlInfoMessageEventArgs (SqlException e) + internal SqlInfoMessageEventArgs (TdsInternalErrorCollection tdsErrors) { - throw new NotImplementedException (); + foreach (TdsInternalError e in tdsErrors) + errors.Add (e.Class, e.LineNumber, e.Message, e.Number, e.Procedure, e.Server, "Mono SqlClient Data Provider", e.State); } #endregion // Constructors #region Properties - [MonoTODO] public SqlErrorCollection Errors { - get { throw new NotImplementedException (); } + get { return errors; } } - [MonoTODO] public string Message { - get { throw new NotImplementedException (); } + get { return errors[0].Message; } } - [MonoTODO] public string Source { - get { throw new NotImplementedException (); } + get { return errors[0].Source; } } #endregion // Properties #region Methods - [MonoTODO] public override string ToString() { - // representation of InfoMessage event - return "'ToString() for SqlInfoMessageEventArgs Not Implemented'"; + return Message; } #endregion // Methods diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatedEventArgs.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatedEventArgs.cs index f3d11b83f63..43df84b02f0 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatedEventArgs.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatedEventArgs.cs @@ -17,22 +17,29 @@ using System.Data.Common; namespace System.Data.SqlClient { public sealed class SqlRowUpdatedEventArgs : RowUpdatedEventArgs { + #region Fields + + SqlCommand command; + + #endregion // Fields + #region Constructors [MonoTODO] public SqlRowUpdatedEventArgs (DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) : base (row, command, statementType, tableMapping) { - throw new NotImplementedException (); + if (!(command is SqlCommand)) + throw new InvalidCastException ("Command is not a SqlCommand object."); + this.command = (SqlCommand) command; } #endregion // Constructors #region Properties - [MonoTODO] public new SqlCommand Command { - get { throw new NotImplementedException (); } + get { return command; } } #endregion // Properties diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatedEventHandler.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatedEventHandler.cs index 8cad2f1cbca..7aaffe10e10 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatedEventHandler.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatedEventHandler.cs @@ -9,10 +9,7 @@ // using System; -using System.Data; -namespace System.Data.SqlClient -{ - public delegate void SqlRowUpdatedEventHandler(object sender, - SqlRowUpdatedEventArgs e); +namespace System.Data.SqlClient { + public delegate void SqlRowUpdatedEventHandler (object sender, SqlRowUpdatedEventArgs e); } diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatingEventArgs.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatingEventArgs.cs index 80ec63c3737..17aa734d62d 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatingEventArgs.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatingEventArgs.cs @@ -17,23 +17,30 @@ using System.Data.Common; namespace System.Data.SqlClient { public sealed class SqlRowUpdatingEventArgs : RowUpdatingEventArgs { + #region Fields + + SqlCommand command; + + #endregion // Fields + #region Constructors [MonoTODO] public SqlRowUpdatingEventArgs (DataRow row, IDbCommand command, StatementType statementType, DataTableMapping tableMapping) : base (row, command, statementType, tableMapping) { - throw new NotImplementedException (); + if (!(command is SqlCommand)) + throw new InvalidCastException ("Command is not a SqlCommand object."); + this.command = (SqlCommand) command; } #endregion // Constructors #region Properties - [MonoTODO] public new SqlCommand Command { - get { throw new NotImplementedException (); } - set { throw new NotImplementedException (); } + get { return command; } + set { command = value; } } #endregion // Properties diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatingEventHandler.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatingEventHandler.cs index 69c0228534d..4d5cbaff984 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatingEventHandler.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlRowUpdatingEventHandler.cs @@ -9,10 +9,7 @@ // using System; -using System.Data; -namespace System.Data.SqlClient -{ - public delegate void SqlRowUpdatingEventHandler(object sender, - SqlRowUpdatingEventArgs e); +namespace System.Data.SqlClient { + public delegate void SqlRowUpdatingEventHandler(object sender, SqlRowUpdatingEventArgs e); } diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlTransaction.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlTransaction.cs index 39e6026b1ed..9cb79e69b98 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlTransaction.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlTransaction.cs @@ -81,7 +81,6 @@ namespace System.Data.SqlClient { return; } connection.Tds.ExecuteNonQuery (commandText); - connection.CheckForErrors (); } public void Commit () @@ -103,7 +102,6 @@ namespace System.Data.SqlClient { if (!isOpen) throw new InvalidOperationException ("The Transaction was not open."); connection.Tds.ExecuteNonQuery ("IF @@TRANCOUNT>0 ROLLBACK TRAN"); - connection.CheckForErrors (); isOpen = false; } @@ -112,7 +110,6 @@ namespace System.Data.SqlClient { if (!isOpen) throw new InvalidOperationException ("The Transaction was not open."); connection.Tds.ExecuteNonQuery (String.Format ("IF @@TRANCOUNT > 0 ROLLBACK TRAN {0}", transactionName)); - connection.CheckForErrors (); isOpen = false; } @@ -121,7 +118,6 @@ namespace System.Data.SqlClient { if (!isOpen) throw new InvalidOperationException ("The Transaction was not open."); connection.Tds.ExecuteNonQuery (String.Format ("SAVE TRAN {0}", savePointName)); - connection.CheckForErrors (); } #endregion // Methods diff --git a/mcs/class/System.Data/list b/mcs/class/System.Data/list index ba96c2e9c91..8d2a5fe9c30 100755 --- a/mcs/class/System.Data/list +++ b/mcs/class/System.Data/list @@ -186,15 +186,16 @@ System.Data.SqlClient/SqlXmlTextReader.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsContext.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsConnectionParameters.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsEnvPacketSubType.cs +../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsInternalErrorMessageEventArgs.cs +../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsInternalErrorMessageEventHandler.cs +../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsInternalInfoMessageEventArgs.cs +../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsInternalInfoMessageEventHandler.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsMessage.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketColumnInfoResult.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketColumnOrderResult.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketColumnNamesResult.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketControlResult.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketEndTokenResult.cs -../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketErrorResult.cs -../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketErrorResultCollection.cs -../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketMessageResult.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketOutputParam.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketResult.cs ../Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketRetStatResult.cs |