Author: suresh
Date: 2005-04-18 01:51:46 -0400 (Mon, 18 Apr 2005)
New Revision: 43192

Modified:
   trunk/mcs/class/System.Data/System.Data.Common/ChangeLog
   trunk/mcs/class/System.Data/System.Data.Common/DataAdapter.cs
   trunk/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
   trunk/mcs/class/System.Data/System.Data/ChangeLog
   trunk/mcs/class/System.Data/System.Data/DataRow.cs
Log:
In System.Data.Common:
2005-04-18  Sureshkumar T  <[EMAIL PROTECTED]>

        * DataAdapter.cs: Implemenetd OnFillError handler.

        * DbDataAdapter.cs: BuildSchema (): the table to be filled might
        contain few additional columns as well. so mapping length should
        be columns' length + fields' length.

In System.Data:
2005-04-18  Sureshkumar T  <[EMAIL PROTECTED]>

        * DataRow.cs: if there are no mapping fields, fill with default
          value.



Modified: trunk/mcs/class/System.Data/System.Data/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data/ChangeLog   2005-04-18 04:56:03 UTC 
(rev 43191)
+++ trunk/mcs/class/System.Data/System.Data/ChangeLog   2005-04-18 05:51:46 UTC 
(rev 43192)
@@ -1,3 +1,8 @@
+2005-04-18  Sureshkumar T  <[EMAIL PROTECTED]>
+
+        * DataRow.cs: if there are no mapping fields, fill with default
+         value.
+
 2005-04-17  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * DataView.cs : Delete() should not try to remove row twice.

Modified: trunk/mcs/class/System.Data/System.Data/DataRow.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data/DataRow.cs  2005-04-18 04:56:03 UTC 
(rev 43191)
+++ trunk/mcs/class/System.Data/System.Data/DataRow.cs  2005-04-18 05:51:46 UTC 
(rev 43192)
@@ -408,9 +408,6 @@
 
                internal void SetValuesFromDataRecord(IDataRecord record, int[] 
mapping)
                {
-                       if ( mapping.Length > Table.Columns.Count)
-                               throw new ArgumentException ();
-
 //                     bool orginalEditing = editing;
 //                     if (!orginalEditing) { 
 //                             BeginEdit ();
@@ -421,8 +418,14 @@
                        }
 
                        try {
-                               for(int i=0; i < mapping.Length; i++) {
+                               for(int i=0; i < Table.Columns.Count; i++) {
                                        DataColumn column = Table.Columns[i];
+                                        if (mapping [i] < 0) { // no mapping
+                                                if (! column.AutoIncrement)
+                                                        column.DataContainer 
[_proposed] = column.DefaultValue;
+                                                continue;
+                                        }
+
                                        
column.DataContainer.SetItemFromDataRecord(_proposed, record,mapping[i]);
                                        if ( column.AutoIncrement ) { 
                                                
column.UpdateAutoIncrementValue(column.DataContainer.GetInt64(_proposed));

Modified: trunk/mcs/class/System.Data/System.Data.Common/ChangeLog
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Common/ChangeLog    2005-04-18 
04:56:03 UTC (rev 43191)
+++ trunk/mcs/class/System.Data/System.Data.Common/ChangeLog    2005-04-18 
05:51:46 UTC (rev 43192)
@@ -1,3 +1,11 @@
+2005-04-18  Sureshkumar T  <[EMAIL PROTECTED]>
+
+       * DataAdapter.cs: Implemenetd OnFillError handler.
+
+       * DbDataAdapter.cs: BuildSchema (): the table to be filled might
+       contain few additional columns as well. so mapping length should
+       be columns' length + fields' length.
+
 2005-03-24  Sureshkumar T  <[EMAIL PROTECTED]>
 
        * DbDataAdapter.cs: Update: If  SourceColumn is null, do not set

Modified: trunk/mcs/class/System.Data/System.Data.Common/DataAdapter.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Common/DataAdapter.cs       
2005-04-18 04:56:03 UTC (rev 43191)
+++ trunk/mcs/class/System.Data/System.Data.Common/DataAdapter.cs       
2005-04-18 05:51:46 UTC (rev 43192)
@@ -243,10 +243,11 @@
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                protected virtual void OnFillError (FillErrorEventArgs value)
                {
-                       throw new NotImplementedException ();
+                       if (FillError != null)
+                               FillError (this, value);
+
                }
 
                [MonoTODO]

Modified: trunk/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs
===================================================================
--- trunk/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs     
2005-04-18 04:56:03 UTC (rev 43191)
+++ trunk/mcs/class/System.Data/System.Data.Common/DbDataAdapter.cs     
2005-04-18 05:51:46 UTC (rev 43192)
@@ -354,12 +354,14 @@
                                } 
                                catch (Exception e) {
                                        object[] readerArray = new 
object[dataReader.FieldCount];
-                                       object[] tableArray = new 
object[mapping.Length];
+                                       object[] tableArray = new 
object[dataReader.FieldCount];
                                        // we get the values from the datareader
                                        dataReader.GetValues (readerArray);
                                        // copy from datareader columns to 
table columns according to given mapping
-                                       for (int i = 0; i < mapping.Length; 
i++) {
-                                               tableArray[i] = 
readerArray[mapping[i]];
+                                        int count = 0;
+                                       for (int i = 0; i < 
dataTable.Columns.Count; i++) {
+                                                if (mapping [i] >= 0)
+                                                        tableArray[count++] = 
readerArray[mapping[i]];
                                        }
                                        FillErrorEventArgs args = 
CreateFillErrorEvent (dataTable, tableArray, e);
                                        OnFillError (args);
@@ -495,7 +497,10 @@
                private int[] BuildSchema (IDataReader reader, DataTable table, 
SchemaType schemaType)
                {
                        int readerIndex = 0;
-                       int[] mapping = new int[reader.FieldCount]; // mapping 
the reader indexes to the datatable indexes
+                       int[] mapping = new int[reader.FieldCount + 
table.Columns.Count]; // mapping the reader indexes to the datatable indexes
+                        for (int i =0 ; i < mapping.Length; i++) 
+                                mapping [i] = -1; // no mapping
+
                        ArrayList primaryKey = new ArrayList ();
                        ArrayList sourceColumns = new ArrayList ();
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to