2002-08-11 Rodrigo Moya <rodrigo@ximian.com>
authorRodrigo Moya <rodrigo@mono-cvs.ximian.com>
Mon, 12 Aug 2002 15:43:20 +0000 (15:43 -0000)
committerRodrigo Moya <rodrigo@mono-cvs.ximian.com>
Mon, 12 Aug 2002 15:43:20 +0000 (15:43 -0000)
* System.Data.OleDb/libgda.cs: added some GdaValue functions.

* System.Data.OleDb/OleDbCommand.cs (OpenReader): removed this
internal method, since we don't need it.
(ExecuteReader): call SetupGdaCommand before executing the command
via libgda functions.
(ExecuteScalar): implemented.

* System.Data.OleDb/OleDbDateReader.cs (OleDbDataReader): removed call
to OleDbCommand.OpenReader.
(GetBoolean): implemented.

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

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

index 32e696741d10ab4e4ef31288d80bec503f61b15c..a36a3f37afae8faf7673cd8a4e7e5642f587aaf8 100644 (file)
@@ -1,10 +1,24 @@
+2002-08-11  Rodrigo Moya <rodrigo@ximian.com>
+
+       * System.Data.OleDb/libgda.cs: added some GdaValue functions.
+
+       * System.Data.OleDb/OleDbCommand.cs (OpenReader): removed this
+       internal method, since we don't need it.
+       (ExecuteReader): call SetupGdaCommand before executing the command
+       via libgda functions.
+       (ExecuteScalar): implemented.
+
+       * System.Data.OleDb/OleDbDateReader.cs (OleDbDataReader): removed call
+       to OleDbCommand.OpenReader.
+       (GetBoolean): implemented.
+
 2002-08-08  Franklin Wise <gracenote@earthlink.net>
 
-       * System.Data.IDbComand.cs: IDbCommand now inherits IDisposable
+       * System.Data/IDbComand.cs: IDbCommand now inherits IDisposable
 
-       * System.Data.IDbConnection.cs: IDbConnection now inherits IDisposable
+       * System.Data/IDbConnection.cs: IDbConnection now inherits IDisposable
 
-       * System.Data.SqlTypes.SqlCompareOptions.cs: Enum now set to correct
+       * System.Data.SqlTypes/SqlCompareOptions.cs: Enum now set to correct
        values.
 
 2002-08-06  Gonzalo Paniagua Javier <gonzalo@ximian.com>
index 5110582cc43db0ec0622e2b250bf2ae13454d46f..7191b72b78ed3beb6b037b82506a506a71ee99d7 100644 (file)
@@ -76,61 +76,101 @@ namespace System.Data.OleDb
        
                public string CommandText 
                {
-                       get { return commandText; }
+                       get {
+                               return commandText;
+                       }
                        set { 
                                commandText = value;
                        }
                }
 
                public int CommandTimeout {
-                       get { return timeout; }
-                       set { timeout = value; }
+                       get {
+                               return timeout;
+                       }
+                       set {
+                               timeout = value;
+                       }
                }
 
                public CommandType CommandType { 
-                       get { return commandType; }
-                       set { commandType = value; }
+                       get {
+                               return commandType;
+                       }
+                       set {
+                               commandType = value;
+                       }
                }
 
                public OleDbConnection Connection { 
-                       get { return connection; }
-                       set { connection = value; }
+                       get {
+                               return connection;
+                       }
+                       set {
+                               connection = value;
+                       }
                }
 
                public bool DesignTimeVisible { 
-                       get { return designTimeVisible; }
-                       set { designTimeVisible = value; }
+                       get {
+                               return designTimeVisible;
+                       }
+                       set {
+                               designTimeVisible = value;
+                       }
                }
 
                public OleDbParameterCollection Parameters {
-                       get { return parameters; }
-                       set { parameters = value; }
+                       get {
+                               return parameters;
+                       }
+                       set {
+                               parameters = value;
+                       }
                }
 
                public OleDbTransaction Transaction {
-                       get { return transaction; }
-                       set { transaction = value; }
+                       get {
+                               return transaction;
+                       }
+                       set {
+                               transaction = value;
+                       }
                }
 
                public UpdateRowSource UpdatedRowSource { 
                        [MonoTODO]
-                       get { throw new NotImplementedException (); }
+                       get {
+                               throw new NotImplementedException ();
+                       }
                        [MonoTODO]
-                       set { throw new NotImplementedException (); }
+                       set {
+                               throw new NotImplementedException ();
+                       }
                }
 
                IDbConnection IDbCommand.Connection {
-                       get { return Connection; }
-                       set { Connection = (OleDbConnection) value; }
+                       get {
+                               return Connection;
+                       }
+                       set {
+                               Connection = (OleDbConnection) value;
+                       }
                }
 
                IDataParameterCollection IDbCommand.Parameters  {
-                       get { return Parameters; }
+                       get {
+                               return Parameters;
+                       }
                }
 
                IDbTransaction IDbCommand.Transaction  {
-                       get { return Transaction; }
-                       set { Transaction = (OleDbTransaction) value; }
+                       get {
+                               return Transaction;
+                       }
+                       set {
+                               Transaction = (OleDbTransaction) value;
+                       }
                }
 
                #endregion // Properties
@@ -198,7 +238,9 @@ namespace System.Data.OleDb
                        IntPtr gdaParameterList = parameters.GdaParameterList;
 
                        SetupGdaCommand ();
-                       return libgda.gda_connection_execute_non_query (gdaConnection, (IntPtr) gdaCommand, gdaParameterList);
+                       return libgda.gda_connection_execute_non_query (gdaConnection,
+                                                                       (IntPtr) gdaCommand,
+                                                                       gdaParameterList);
                }
 
                public OleDbDataReader ExecuteReader ()
@@ -223,6 +265,7 @@ namespace System.Data.OleDb
                        IntPtr gdaConnection = connection.GdaConnection;
                        IntPtr gdaParameterList = parameters.GdaParameterList;
 
+                       SetupGdaCommand ();
                        /* FIXME: split all returned resultsets into the array
                           list of results */
                        results.Add (libgda.gda_connection_execute_command (
@@ -241,10 +284,11 @@ namespace System.Data.OleDb
                        return ExecuteReader (behavior);
                }
                
-               [MonoTODO]
                public object ExecuteScalar ()
                {
-                       throw new NotImplementedException ();   
+                       SetupGdaCommand ();
+                       OleDbDataReader reader = ExecuteReader ();
+                       return reader.GetValue (0);
                }
 
                [MonoTODO]
@@ -265,17 +309,5 @@ namespace System.Data.OleDb
                }
 
                #endregion
-
-               #region Internal Methods
-
-               // only meant to be used between OleDbConnection,
-               // OleDbCommand, and OleDbDataReader
-               internal void OpenReader (OleDbDataReader reader) 
-               {
-                       connection.OpenReader (reader);
-               }
-
-               #endregion
-
        }
 }
index e8fd7ae8b43ed290cf4b6d6d29a3935c21377b76..a91c8a6759e4ca19de744383dee66e85dc1d5b76 100644 (file)
@@ -41,7 +41,6 @@ namespace System.Data.OleDb
                                gdaResults = new ArrayList ();
                        currentResult = -1;
                        currentRow = -1;
-                       command.OpenReader(this);
                        isOpened = true;
                }
 
@@ -51,7 +50,9 @@ namespace System.Data.OleDb
 
                public int Depth {
                        [MonoTODO]
-                       get { throw new NotImplementedException (); }
+                       get {
+                               throw new NotImplementedException ();
+                       }
                }
 
                public int FieldCount {
@@ -126,10 +127,22 @@ namespace System.Data.OleDb
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public bool GetBoolean (int ordinal)
                {
-                       throw new NotImplementedException ();
+                       IntPtr value;
+
+                       if (currentResult == -1)
+                               return false;
+
+                       value = libgda.gda_data_model_get_value_at ((IntPtr) gdaResults[currentResult],
+                                                                   ordinal, currentRow);
+                       if (value != IntPtr.Zero) {
+                               if (libgda.gda_value_get_vtype (value) != GdaValueType.Boolean)
+                                       throw new InvalidCastException ();
+                               return libgda.gda_value_get_boolean (value);
+                       }
+
+                       return false;
                }
 
                [MonoTODO]
@@ -299,7 +312,6 @@ namespace System.Data.OleDb
                        return false;
                }
 
-               [MonoTODO]
                public bool Read ()
                {
                        throw new NotImplementedException ();
index 812b2518d24e9aa47240e49167e0ed50b8d1ef77..2becacc4aef4c709ddb07d2031c1a01b839bd107 100644 (file)
@@ -17,6 +17,8 @@ namespace System.Data.OleDb.Test
                {
                        string sql = "SELECT * FROM pg_tables";
                        OleDbCommand cmd = new OleDbCommand (sql, m_cnc);
+
+                       IDataReader reader = cmd.ExecuteReader ();
                }
 
                void Close ()
index 97f1baf82cd1aef4910cff551345196bf6d25c4f..cb1afebd681c0715c5883078634c9dd6258258d6 100644 (file)
@@ -29,6 +29,27 @@ namespace System.Data.OleDb
                Schema = 4,
                Invalid = 5
        };
+
+       internal enum GdaValueType {
+               Null = 0,
+               Bigint = 1,
+               Binary = 2,
+               Boolean = 3,
+               Date = 4,
+               Double = 5,
+               GeometricPoint = 6,
+               Integer = 7,
+               List = 8,
+               Numeric = 9,
+               Single = 10,
+               Smallint = 11,
+               String = 12,
+               Time = 13,
+               Timestamp = 14,
+               Tinyint = 15,
+               Type = 16,
+               Unknown = 17
+       };
        
        sealed internal class libgda
        {
@@ -47,6 +68,12 @@ 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 GdaValueType gda_value_get_vtype (IntPtr value);
+
+               [DllImport("gda-2")]
+               public static extern bool gda_value_get_boolean (IntPtr value);
+               
                [DllImport("gda-2")]
                public static extern int gda_data_model_get_n_rows (IntPtr model);