2002-07-30 Rodrigo Moya <rodrigo@ximian.com>
authorRodrigo Moya <rodrigo@mono-cvs.ximian.com>
Tue, 30 Jul 2002 23:21:29 +0000 (23:21 -0000)
committerRodrigo Moya <rodrigo@mono-cvs.ximian.com>
Tue, 30 Jul 2002 23:21:29 +0000 (23:21 -0000)
* OleDbDataReader.cs (FieldCount): implemented.
(IsClosed, Item, RecordsAffected): implemented some properties.

* libgda.cs: added GdaDataModel methods.

svn path=/trunk/mcs/; revision=6266

mcs/class/System.Data/System.Data.OleDb/ChangeLog
mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs
mcs/class/System.Data/System.Data.OleDb/libgda.cs

index b925ff490111450d8ecd619080f1616dbb934e19..610c112745844864f5513c4ed4e3b187432a2441 100644 (file)
@@ -1,3 +1,10 @@
+2002-07-30  Rodrigo Moya <rodrigo@ximian.com>
+
+       * OleDbDataReader.cs (FieldCount): implemented.
+       (IsClosed, Item, RecordsAffected): implemented some properties.
+
+       * libgda.cs: added GdaDataModel methods.
+
 2002-07-29  Rodrigo Moya <rodrigo@ximian.com>
 
        * OleDbDataReader.cs (OleDbDataReader constructor): changed to receive
index 3e96f4fe5c64ad7c5dfbd38b1d0dc2f7f07fc2f1..e8fd7ae8b43ed290cf4b6d6d29a3935c21377b76 100644 (file)
@@ -24,6 +24,8 @@ namespace System.Data.OleDb
                private bool open;
                private ArrayList gdaResults;
                private int currentResult;
+               private int currentRow;
+               private bool isOpened;
 
                #endregion
 
@@ -33,9 +35,14 @@ namespace System.Data.OleDb
                {
                        this.command = command;
                        open = true;
-                       gdaResults = results;
+                       if (results != null)
+                               gdaResults = results;
+                       else
+                               gdaResults = new ArrayList ();
                        currentResult = -1;
+                       currentRow = -1;
                        command.OpenReader(this);
+                       isOpened = true;
                }
 
                #endregion
@@ -48,13 +55,20 @@ namespace System.Data.OleDb
                }
 
                public int FieldCount {
-                       [MonoTODO]
-                       get { throw new NotImplementedException (); }
+                       get {
+                               if (currentResult < 0 ||
+                                   currentResult >= gdaResults.Count)
+                                       return 0;
+
+                               return libgda.gda_data_model_get_n_columns (
+                                       (IntPtr) gdaResults[currentResult]);
+                       }
                }
 
                public bool IsClosed {
-                       [MonoTODO]
-                       get { throw new NotImplementedException (); }
+                       get {
+                               return !isOpened;
+                       }
                }
 
                public object this[string name] {
@@ -63,13 +77,37 @@ namespace System.Data.OleDb
                }
 
                public object this[int index] {
-                       [MonoTODO]
-                       get { throw new NotImplementedException (); }
+                       get {
+                               if (currentResult < 0 ||
+                                   currentResult >= gdaResults.Count)
+                                       return null;
+                               
+                               return libgda.gda_data_model_get_value_at (
+                                               (IntPtr) gdaResults[currentResult],
+                                               index,
+                                               currentRow);
+                       }
                }
 
                public int RecordsAffected {
-                       [MonoTODO]
-                       get { throw new NotImplementedException (); }
+                       get {
+                               int total_rows;
+                               
+                               if (currentResult < 0 ||
+                                   currentResult >= gdaResults.Count)
+                                       return 0;
+
+                               total_rows = libgda.gda_data_model_get_n_rows (
+                                       (IntPtr) gdaResults[currentResult]);
+                               if (total_rows > 0) {
+                                       if (FieldCount > 0) {
+                                               // It's a SELECT statement
+                                               return -1;
+                                       }
+                               }
+
+                               return FieldCount > 0 ? -1 : total_rows;
+                       }
                }
 
                #endregion
index 1d2811ff328d53b33b4a59b720115d70049af57f..a8b55239a8db6cc63a1658af29bc50f4784610db 100644 (file)
@@ -52,6 +52,15 @@ namespace System.Data.OleDb
                [DllImport("gda-2")]
                public static extern void gda_init (string app_id, string version, int nargs, string[] args);
 
+               [DllImport("gda-2")]
+               public static extern int gda_data_model_get_n_rows (IntPtr model);
+
+               [DllImport("gda-2")]
+               public static extern int gda_data_model_get_n_columns (IntPtr model);
+
+               [DllImport("gda-2")]
+               public static extern IntPtr gda_data_model_get_value_at (IntPtr model, int col, int row);
+               
                [DllImport("gda-2")]
                public static extern IntPtr gda_client_new ();