Hello:

Sorry, the Patch file!!




Best regards
Carlos Guzm�n �lvarez
Vigo-Spain
Index: SqlCommandBuilder.cs
===================================================================
RCS file: /mono/mcs/class/System.Data/System.Data.SqlClient/SqlCommandBuilder.cs,v
retrieving revision 1.7
diff -u -r1.7 SqlCommandBuilder.cs
--- SqlCommandBuilder.cs        13 Nov 2002 17:32:22 -0000      1.7
+++ SqlCommandBuilder.cs        6 Dec 2002 12:21:02 -0000
@@ -174,9 +174,11 @@
                                if (!isKey) {
                                        parameter = deleteCommand.Parameters.Add 
(CreateParameter (parmIndex++, schemaRow));
 
-                                       dsColumnName = tableMapping.ColumnMappings 
[parameter.SourceColumn].DataSetColumn;
-                                       if (row != null)
-                                               parameter.Value = row [dsColumnName, 
DataRowVersion.Current];
+                                       if (tableMapping != null) {
+                                               dsColumnName = 
+tableMapping.ColumnMappings [parameter.SourceColumn].DataSetColumn;
+                                               if (row != null)
+                                                       parameter.Value = row 
+[dsColumnName, DataRowVersion.Current];
+                                       }
                                        where.Append ("(");
                                        where.Append (String.Format (clause1, 
GetQuotedString (parameter.SourceColumn), parameter.ParameterName));
                                        where.Append (" OR ");
@@ -186,9 +188,11 @@
                                        
                                parameter = deleteCommand.Parameters.Add 
(CreateParameter (parmIndex++, schemaRow));
 
-                               dsColumnName = tableMapping.ColumnMappings 
[parameter.SourceColumn].DataSetColumn;
-                               if (row != null)
-                                       parameter.Value = row [dsColumnName, 
DataRowVersion.Current];
+                               if (tableMapping != null) {
+                                       dsColumnName = tableMapping.ColumnMappings 
+[parameter.SourceColumn].DataSetColumn;
+                                       if (row != null)
+                                               parameter.Value = row [dsColumnName, 
+DataRowVersion.Current];
+                               }
 
                                where.Append (String.Format (clause2, GetQuotedString 
(parameter.SourceColumn), parameter.ParameterName));
 
@@ -229,9 +233,11 @@
 
                                SqlParameter parameter = insertCommand.Parameters.Add 
(CreateParameter (parmIndex++, schemaRow));
 
-                               dsColumnName = tableMapping.ColumnMappings 
[parameter.SourceColumn].DataSetColumn;
-                               if (row != null)
-                                       parameter.Value = row [dsColumnName];
+                               if (tableMapping != null) {
+                                       dsColumnName = tableMapping.ColumnMappings 
+[parameter.SourceColumn].DataSetColumn;
+                                       if (row != null)
+                                               parameter.Value = row [dsColumnName];
+                               }
 
                                columns.Append (GetQuotedString 
(parameter.SourceColumn));
                                values.Append (parameter.ParameterName);
@@ -276,9 +282,11 @@
 
                                SqlParameter parameter = updateCommand.Parameters.Add 
(CreateParameter (parmIndex++, schemaRow));
 
-                               dsColumnName = tableMapping.ColumnMappings 
[parameter.SourceColumn].DataSetColumn;
-                               if (row != null)
-                                       parameter.Value = row [dsColumnName, 
DataRowVersion.Proposed];
+                               if (tableMapping != null) {
+                                       dsColumnName = tableMapping.ColumnMappings 
+[parameter.SourceColumn].DataSetColumn;
+                                       if (row != null)
+                                               parameter.Value = row [dsColumnName, 
+DataRowVersion.Proposed];
+                               }
 
                                columns.Append (String.Format ("{0} = {1}", 
GetQuotedString (parameter.SourceColumn), parameter.ParameterName));
                        }
@@ -312,9 +320,11 @@
                                        
                                parameter = updateCommand.Parameters.Add 
(CreateParameter (parmIndex++, schemaRow));
 
-                               dsColumnName = tableMapping.ColumnMappings 
[parameter.SourceColumn].DataSetColumn;
-                               if (row != null)
-                                       parameter.Value = row [dsColumnName];
+                               if (tableMapping != null) {
+                                       dsColumnName = tableMapping.ColumnMappings 
+[parameter.SourceColumn].DataSetColumn;
+                                       if (row != null)
+                                               parameter.Value = row [dsColumnName];
+                               }
 
                                where.Append (String.Format (clause2, GetQuotedString 
(parameter.SourceColumn), parameter.ParameterName));
 
@@ -409,14 +419,16 @@
 
                private bool IncludedInUpdate (DataRow schemaRow)
                {
-                       // If the parameter has one of these properties, then we don't 
include it in the insert:
-                       // AutoIncrement, Hidden, RowVersion
+                       // If the parameter has one of these properties, then we don't 
+include it in the update:
+                       // AutoIncrement, Hidden, RowVersion, ReadOnly
 
                        if ((bool) schemaRow ["IsAutoIncrement"])
                                return false;
                        if ((bool) schemaRow ["IsHidden"])
                                return false;
                        if ((bool) schemaRow ["IsRowVersion"])
+                               return false;
+                       if ((bool) schemaRow ["IsReadOnly"])
                                return false;
                        return true;
                }

Reply via email to