2002-08-15 Rodrigo Moya <rodrigo@ximian.com>
authorRodrigo Moya <rodrigo@mono-cvs.ximian.com>
Fri, 16 Aug 2002 01:19:29 +0000 (01:19 -0000)
committerRodrigo Moya <rodrigo@mono-cvs.ximian.com>
Fri, 16 Aug 2002 01:19:29 +0000 (01:19 -0000)
* System.Data/UniqueConstraint.cs (UniqueConstraint): commented
unreachable code to avoid compiler warning.

* System.Data.OleDb/libgda.cs (GdaList): added new internal class.

* System.Data.OleDb/OleDbConnection.cs (DataSource): implemented.
(OpenReader): removed internal method.

* System.Data.OleDb/OleDbCommand.cs (ExecuteReader): split correctly
the list of returned data models.

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

mcs/class/System.Data/ChangeLog
mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs
mcs/class/System.Data/System.Data.OleDb/OleDbConnection.cs
mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs
mcs/class/System.Data/System.Data.OleDb/libgda.cs
mcs/class/System.Data/System.Data/UniqueConstraint.cs

index d02e77653d554cc2aa9cb0d138e557e936fb53c8..b99a3ad1b30e97da7bf1dd3ca2dd07ff81a0e490 100644 (file)
@@ -1,3 +1,16 @@
+2002-08-15  Rodrigo Moya <rodrigo@ximian.com>
+
+       * System.Data/UniqueConstraint.cs (UniqueConstraint): commented
+       unreachable code to avoid compiler warning.
+
+       * System.Data.OleDb/libgda.cs (GdaList): added new internal class.
+
+       * System.Data.OleDb/OleDbConnection.cs (DataSource): implemented.
+       (OpenReader): removed internal method.
+
+       * System.Data.OleDb/OleDbCommand.cs (ExecuteReader): split correctly
+       the list of returned data models.
+
 2002-08-15  Franklin Wise <gracenote@earthlink.net>
        
        * System.Data/Constraint.cs: Added helper virtual functions
index 7191b72b78ed3beb6b037b82506a506a71ee99d7..d5d304dd80ae1c653f6b8baf826dc07867e9fe48 100644 (file)
@@ -13,6 +13,7 @@ using System.ComponentModel;
 using System.Data;
 using System.Data.Common;
 using System.Collections;
+using System.Runtime.InteropServices;
 
 namespace System.Data.OleDb
 {
@@ -52,8 +53,7 @@ namespace System.Data.OleDb
                        gdaCommand = IntPtr.Zero;
                }
 
-               public OleDbCommand (string cmdText)
-                       : this ()
+               public OleDbCommand (string cmdText) : this ()
                {
                        CommandText = cmdText;
                }
@@ -64,8 +64,9 @@ namespace System.Data.OleDb
                        Connection = connection;
                }
 
-               public OleDbCommand (string cmdText, OleDbConnection connection, OleDbTransaction transaction)
-                       : this (cmdText, connection)
+               public OleDbCommand (string cmdText,
+                                    OleDbConnection connection,
+                                    OleDbTransaction transaction) : this (cmdText, connection)
                {
                        this.transaction = transaction;
                }
@@ -256,6 +257,8 @@ namespace System.Data.OleDb
                public OleDbDataReader ExecuteReader (CommandBehavior behavior)
                {
                        ArrayList results = new ArrayList ();
+                       IntPtr rs_list;
+                       GdaList glist_node;
 
                        if (connection.State != ConnectionState.Open)
                                throw new InvalidOperationException ();
@@ -265,16 +268,23 @@ namespace System.Data.OleDb
                        IntPtr gdaConnection = connection.GdaConnection;
                        IntPtr gdaParameterList = parameters.GdaParameterList;
 
+                       /* execute the command */
                        SetupGdaCommand ();
-                       /* FIXME: split all returned resultsets into the array
-                          list of results */
-                       results.Add (libgda.gda_connection_execute_command (
-                                               gdaConnection,
-                                               gdaCommand,
-                                               gdaParameterList));
-
-                       dataReader = new OleDbDataReader (this, results);
-                       dataReader.NextResult ();
+                       rs_list = libgda.gda_connection_execute_command (
+                               gdaConnection,
+                               gdaCommand,
+                               gdaParameterList);
+                       if (rs_list != IntPtr.Zero) {
+                               glist_node = (GdaList) Marshal.PtrToStructure (rs_list, typeof (GdaList));
+
+                               while (glist_node != null) {
+                                       results.Add (glist_node.data);
+                                       glist_node = (GdaList) Marshal.PtrToStructure (glist_node.next,
+                                                                                      typeof (GdaList));
+                               }
+                               dataReader = new OleDbDataReader (this, results);
+                               dataReader.NextResult ();
+                       }
 
                        return dataReader;
                }
index 94b8b208e6bcbd7cfe95471dfbe5fe05dd246c3e..f544494bb4ad92817f92e3113031383a260a3fa2 100644 (file)
@@ -63,7 +63,8 @@ namespace System.Data.OleDb
 
                public string Database { 
                        get {
-                               if (gdaConnection != IntPtr.Zero && libgda.gda_connection_is_open (gdaConnection)) {
+                               if (gdaConnection != IntPtr.Zero
+                                   && libgda.gda_connection_is_open (gdaConnection)) {
                                        return libgda.gda_connection_get_database (gdaConnection);
                                }
 
@@ -72,15 +73,20 @@ namespace System.Data.OleDb
                }
 
                public string DataSource {
-                       [MonoTODO]
                        get {
-                               throw new NotImplementedException ();
+                               if (gdaConnection != IntPtr.Zero
+                                   && libgda.gda_connection_is_open (gdaConnection)) {
+                                       return libgda.gda_connection_get_dsn (gdaConnection);
+                               }
+
+                               return null;
                        }
                }
 
                public string Provider {
                        get {
-                               if (gdaConnection != IntPtr.Zero && libgda.gda_connection_is_open (gdaConnection)) {
+                               if (gdaConnection != IntPtr.Zero
+                                   && libgda.gda_connection_is_open (gdaConnection)) {
                                        return libgda.gda_connection_get_provider (gdaConnection);
                                }
 
@@ -159,7 +165,8 @@ namespace System.Data.OleDb
 
                public OleDbCommand CreateCommand ()
                {
-                       if (gdaConnection != IntPtr.Zero && libgda.gda_connection_is_open (gdaConnection))
+                       if (gdaConnection != IntPtr.Zero
+                           && libgda.gda_connection_is_open (gdaConnection))
                                return new OleDbCommand (null, this);
 
                        return null;
@@ -204,28 +211,6 @@ namespace System.Data.OleDb
                        throw new NotImplementedException ();
                }
 
-               #endregion
-
-               #region Internal Methods
-
-               // Used to prevent OleDbConnection
-               // from doing anything while
-               // OleDbDataReader is open.
-               // Open the Reader. (called from OleDbCommand)
-               internal void OpenReader (OleDbDataReader reader)
-               {
-                       if(dataReaderOpen == true) {
-                               // TODO: throw exception here?
-                               //       because a reader
-                               //       is already open
-                       }
-                       else {
-                               dataReader = reader;
-                               dataReaderOpen = true;
-                       }
-               }
-
-
                #endregion
 
                #region Events and Delegates
index a91c8a6759e4ca19de744383dee66e85dc1d5b76..afe0ed673f40847c64d8ff389b4d119ff105aede 100644 (file)
@@ -25,7 +25,6 @@ namespace System.Data.OleDb
                private ArrayList gdaResults;
                private int currentResult;
                private int currentRow;
-               private bool isOpened;
 
                #endregion
 
@@ -41,7 +40,6 @@ namespace System.Data.OleDb
                                gdaResults = new ArrayList ();
                        currentResult = -1;
                        currentRow = -1;
-                       isOpened = true;
                }
 
                #endregion
@@ -68,13 +66,15 @@ namespace System.Data.OleDb
 
                public bool IsClosed {
                        get {
-                               return !isOpened;
+                               return !open;
                        }
                }
 
                public object this[string name] {
                        [MonoTODO]
-                       get { throw new NotImplementedException (); }
+                       get {
+                               throw new NotImplementedException ();
+                       }
                }
 
                public object this[int index] {
@@ -306,6 +306,7 @@ namespace System.Data.OleDb
                        int i = currentResult + 1;
                        if (i >= 0 && i < gdaResults.Count) {
                                currentResult++;
+                               currentRow = 0;
                                return true;
                        }
 
index cb1afebd681c0715c5883078634c9dd6258258d6..17a1f163611dad67791de0383542b0493ac76b5e 100644 (file)
@@ -50,6 +50,14 @@ namespace System.Data.OleDb
                Type = 16,
                Unknown = 17
        };
+
+       [StructLayout(LayoutKind.Sequential)]
+       internal class GdaList
+       {
+               public IntPtr data;
+               public IntPtr next;
+               public IntPtr prev;
+       }
        
        sealed internal class libgda
        {
index 57a14eb68c668419ef07fe7dee4bfc5622e78610..517222df63aedf68e7630b9560514df6bb510933 100644 (file)
@@ -77,7 +77,7 @@ namespace System.Data
                        string[] columnNames, bool isPrimaryKey) {
 
                        throw new NotImplementedException(); //need to finish related logic
-
+                       /*
                        base.ConstraintName = name;
                        
                        //set unique
@@ -87,6 +87,7 @@ namespace System.Data
                        _dataColumnNames = columnNames;
 
                        _isPrimaryKey = isPrimaryKey;
+                       */
                }
 
                //helper ctor