diff options
author | Sureshkumar T <suresh@mono-cvs.ximian.com> | 2005-07-15 17:15:36 +0400 |
---|---|---|
committer | Sureshkumar T <suresh@mono-cvs.ximian.com> | 2005-07-15 17:15:36 +0400 |
commit | 425bc04d754217f5c24880d1af17fade4409018a (patch) | |
tree | 32a02bdd72b28b00b84889dfe20355d5774b9bff /mcs/class/System.Data/System.Data.SqlClient | |
parent | d6b3ee3d3ad2ba9716e5dee9917a838a9e97beec (diff) |
In System.Data.Common:
2005-07-15 Sureshkumar T <tsureshkumar@novell.com>
* DataTableMappingCollection.cs: GetTableMappingBySchemaAction:
meaningful error message if mapping is missing.
* DbDataAdapter.cs: Update: meaningful message if table is missing.
In System.Data.SqlClient:
2005-07-15 Sureshkumar T <tsureshkumar@novell.com>
* SqlCommandBuilder.cs:
- set_DataAdapter: unsubscribe event if DataAdapter is reset.
- CreateInsertCommand, CreateUpdateCommand, CreateDeleteCommand:
if column mapping is missing, use the source column name. use
proper version to get the data.
- RowUpdatingHandler: set status to continue to actually process
the query.
svn path=/trunk/mcs/; revision=47340
Diffstat (limited to 'mcs/class/System.Data/System.Data.SqlClient')
-rw-r--r-- | mcs/class/System.Data/System.Data.SqlClient/ChangeLog | 10 | ||||
-rw-r--r-- | mcs/class/System.Data/System.Data.SqlClient/SqlCommandBuilder.cs | 55 |
2 files changed, 52 insertions, 13 deletions
diff --git a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog index ed732c6a3d6..9cdc9989222 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/ChangeLog +++ b/mcs/class/System.Data/System.Data.SqlClient/ChangeLog @@ -1,3 +1,13 @@ +2005-07-15 Sureshkumar T <tsureshkumar@novell.com> + + * SqlCommandBuilder.cs: + - set_DataAdapter: unsubscribe event if DataAdapter is reset. + - CreateInsertCommand, CreateUpdateCommand, CreateDeleteCommand: + if column mapping is missing, use the source column name. use + proper version to get the data. + - RowUpdatingHandler: set status to continue to actually process + the query. + 2005-07-04 Ben Maurer <bmaurer@ximian.com> * SqlError.cs: Patch from dezelin@gmail.com to fix serialization. diff --git a/mcs/class/System.Data/System.Data.SqlClient/SqlCommandBuilder.cs b/mcs/class/System.Data/System.Data.SqlClient/SqlCommandBuilder.cs index 34aaf6b82f5..5e524a4f22f 100644 --- a/mcs/class/System.Data/System.Data.SqlClient/SqlCommandBuilder.cs +++ b/mcs/class/System.Data/System.Data.SqlClient/SqlCommandBuilder.cs @@ -90,7 +90,11 @@ namespace System.Data.SqlClient { public new SqlDataAdapter DataAdapter { get { return adapter; } set { + if (adapter != null) + adapter.RowUpdating -= new SqlRowUpdatingEventHandler (RowUpdatingHandler); + adapter = value; + if (adapter != null) adapter.RowUpdating += new SqlRowUpdatingEventHandler (RowUpdatingHandler); } @@ -212,9 +216,13 @@ namespace System.Data.SqlClient { if (!isKey) { parameter = deleteCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow)); - dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + dsColumnName = parameter.SourceColumn; + if (tableMapping != null + && tableMapping.ColumnMappings.Contains (parameter.SourceColumn)) + dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + if (row != null) - parameter.Value = row [dsColumnName, DataRowVersion.Current]; + parameter.Value = row [dsColumnName, DataRowVersion.Original]; whereClause.Append ("("); whereClause.Append (String.Format (clause1, GetQuotedString (parameter.SourceColumn), parameter.ParameterName)); whereClause.Append (" OR "); @@ -224,9 +232,13 @@ namespace System.Data.SqlClient { parameter = deleteCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow)); - dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + dsColumnName = parameter.SourceColumn; + if (tableMapping != null + && tableMapping.ColumnMappings.Contains (parameter.SourceColumn)) + dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + if (row != null) - parameter.Value = row [dsColumnName, DataRowVersion.Current]; + parameter.Value = row [dsColumnName, DataRowVersion.Original]; whereClause.Append (String.Format (clause2, GetQuotedString (parameter.SourceColumn), parameter.ParameterName)); @@ -267,7 +279,11 @@ namespace System.Data.SqlClient { SqlParameter parameter = insertCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow)); - dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + dsColumnName = parameter.SourceColumn; + if (tableMapping != null + && tableMapping.ColumnMappings.Contains (parameter.SourceColumn)) + dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + if (row != null) parameter.Value = row [dsColumnName]; @@ -314,9 +330,13 @@ namespace System.Data.SqlClient { SqlParameter parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow)); - dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + dsColumnName = parameter.SourceColumn; + if (tableMapping != null + && tableMapping.ColumnMappings.Contains (parameter.SourceColumn)) + dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + if (row != null) - parameter.Value = row [dsColumnName, DataRowVersion.Proposed]; + parameter.Value = row [dsColumnName, DataRowVersion.Original]; columns.Append (String.Format ("{0} = {1}", GetQuotedString (parameter.SourceColumn), parameter.ParameterName)); } @@ -337,9 +357,13 @@ namespace System.Data.SqlClient { if (!isKey) { parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow)); - dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + dsColumnName = parameter.SourceColumn; + if (tableMapping != null + && tableMapping.ColumnMappings.Contains (parameter.SourceColumn)) + dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + if (row != null) - parameter.Value = row [dsColumnName]; + parameter.Value = row [dsColumnName, DataRowVersion.Original]; whereClause.Append ("("); whereClause.Append (String.Format (clause1, GetQuotedString (parameter.SourceColumn), parameter.ParameterName)); @@ -350,9 +374,13 @@ namespace System.Data.SqlClient { parameter = updateCommand.Parameters.Add (CreateParameter (parmIndex++, schemaRow)); - dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + dsColumnName = parameter.SourceColumn; + if (tableMapping != null + && tableMapping.ColumnMappings.Contains (parameter.SourceColumn)) + dsColumnName = tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn; + if (row != null) - parameter.Value = row [dsColumnName]; + parameter.Value = row [dsColumnName, DataRowVersion.Original]; whereClause.Append (String.Format (clause2, GetQuotedString (parameter.SourceColumn), parameter.ParameterName)); @@ -557,8 +585,9 @@ namespace System.Data.SqlClient { } if (e.Command != null && e.Row != null) { - e.Row.AcceptChanges (); - e.Status = UpdateStatus.SkipCurrentRow; + if (e.StatementType != StatementType.Delete) + e.Row.AcceptChanges (); + e.Status = UpdateStatus.Continue; } } catch (Exception exception) { |