From: Rodrigo Moya Date: Mon, 12 Aug 2002 15:43:20 +0000 (-0000) Subject: 2002-08-11 Rodrigo Moya X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=791551a1fdf3654ca477a11564202d3280e4c334;p=mono.git 2002-08-11 Rodrigo Moya * 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 --- diff --git a/mcs/class/System.Data/ChangeLog b/mcs/class/System.Data/ChangeLog index 32e696741d1..a36a3f37afa 100644 --- a/mcs/class/System.Data/ChangeLog +++ b/mcs/class/System.Data/ChangeLog @@ -1,10 +1,24 @@ +2002-08-11 Rodrigo Moya + + * 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 - * 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 diff --git a/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs b/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs index 5110582cc43..7191b72b78e 100644 --- a/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs +++ b/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs @@ -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 - } } diff --git a/mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs b/mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs index e8fd7ae8b43..a91c8a6759e 100644 --- a/mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs +++ b/mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs @@ -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 (); diff --git a/mcs/class/System.Data/System.Data.OleDb/TestOleDb.cs b/mcs/class/System.Data/System.Data.OleDb/TestOleDb.cs index 812b2518d24..2becacc4aef 100644 --- a/mcs/class/System.Data/System.Data.OleDb/TestOleDb.cs +++ b/mcs/class/System.Data/System.Data.OleDb/TestOleDb.cs @@ -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 () diff --git a/mcs/class/System.Data/System.Data.OleDb/libgda.cs b/mcs/class/System.Data/System.Data.OleDb/libgda.cs index 97f1baf82cd..cb1afebd681 100644 --- a/mcs/class/System.Data/System.Data.OleDb/libgda.cs +++ b/mcs/class/System.Data/System.Data.OleDb/libgda.cs @@ -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);