From 9e3aae2189f63206816bffa2c98948df00a26698 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Sun, 28 Jul 2002 23:28:55 +0000 Subject: [PATCH] 2002-07-28 Rodrigo Moya * OleDbCommand.cs (ExecuteReader): (CreateParameter): implemented IDbCommand methods. (CommandText): don't create many GdaCommand's, only one is needed. (ExecuteNonQuery): set up the internal GDA command object. (ExecuteReader): use correctly the unique GDA command object. * libgda.cs: added new libgda calls. svn path=/trunk/mcs/; revision=6232 --- .../System.Data/System.Data.OleDb/ChangeLog | 15 ++++ .../System.Data.OleDb/OleDbCommand.cs | 84 ++++++++++++------- .../System.Data.OleDb/OleDbTransaction.cs | 8 +- .../System.Data/System.Data.OleDb/libgda.cs | 11 ++- 4 files changed, 82 insertions(+), 36 deletions(-) diff --git a/mcs/class/System.Data/System.Data.OleDb/ChangeLog b/mcs/class/System.Data/System.Data.OleDb/ChangeLog index afbf83399cb..8e769cfc1cf 100644 --- a/mcs/class/System.Data/System.Data.OleDb/ChangeLog +++ b/mcs/class/System.Data/System.Data.OleDb/ChangeLog @@ -1,3 +1,18 @@ +2002-07-28 Rodrigo Moya + + * OleDbCommand.cs (ExecuteReader): + (CreateParameter): implemented IDbCommand methods. + (CommandText): don't create many GdaCommand's, only one is needed. + (ExecuteNonQuery): set up the internal GDA command object. + (ExecuteReader): use correctly the unique GDA command object. + + * libgda.cs: added new libgda calls. + +2002-07-27 Rodrigo Moya + + * OleDbConnection.cs (CreateCommand): + (BeginTransaction): implemented IDbConnection methods. + 2002-07-11 Rodrigo Moya * libgda.cs: added new libgda functions and some enumerations. diff --git a/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs b/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs index 87bcfeb5bd8..127f3c8f400 100644 --- a/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs +++ b/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs @@ -32,7 +32,7 @@ namespace System.Data.OleDb bool designTimeVisible; OleDbDataReader dataReader; CommandBehavior behavior; - ArrayList gdaCommands; + IntPtr gdaCommand; ArrayList gdaResults; #endregion // Fields @@ -50,7 +50,7 @@ namespace System.Data.OleDb designTimeVisible = false; dataReader = null; behavior = CommandBehavior.Default; - gdaCommands = new ArrayList (); + gdaCommand = IntPtr.Zero; gdaResults = new ArrayList (); } @@ -80,13 +80,7 @@ namespace System.Data.OleDb { get { return commandText; } set { - string[] queries = value.Split (new Char[] {';'}); - gdaCommands.Clear (); - - foreach (string query in queries) - gdaCommands.Add (libgda.gda_command_new (query, 0, 0)); - - commandText = value; + commandText = value; } } @@ -160,12 +154,44 @@ namespace System.Data.OleDb return new OleDbParameter (); } + IDbDataParameter IDbCommand.CreateParameter () + { + return CreateParameter (); + } + [MonoTODO] protected override void Dispose (bool disposing) { throw new NotImplementedException (); } + private void SetupGdaCommand () + { + GdaCommandType type; + + switch (commandType) { + case CommandType.TableDirect : + type = GdaCommandType.Table; + break; + case CommandType.StoredProcedure : + type = GdaCommandType.Procedure; + break; + case CommandType.Text : + default : + type = GdaCommandType.Sql; + break; + } + + if (gdaCommand != IntPtr.Zero) { + libgda.gda_command_set_text (gdaCommand, commandText); + libgda.gda_command_set_command_type (gdaCommand, type); + } else { + gdaCommand = libgda.gda_command_new (commandText, type, 0); + } + + //libgda.gda_command_set_transaction + } + public int ExecuteNonQuery () { if (connection == null) @@ -177,7 +203,8 @@ namespace System.Data.OleDb IntPtr gdaConnection = connection.GdaConnection; IntPtr gdaParameterList = parameters.GdaParameterList; - return libgda.gda_connection_execute_non_query (gdaConnection, (IntPtr) gdaCommands[0], gdaParameterList); + SetupGdaCommand (); + return libgda.gda_connection_execute_non_query (gdaConnection, (IntPtr) gdaCommand, gdaParameterList); } public OleDbDataReader ExecuteReader () @@ -185,6 +212,11 @@ namespace System.Data.OleDb return ExecuteReader (CommandBehavior.Default); } + IDataReader IDbCommand.ExecuteReader () + { + return ExecuteReader (); + } + public OleDbDataReader ExecuteReader (CommandBehavior behavior) { if (connection.State != ConnectionState.Open) @@ -195,42 +227,32 @@ namespace System.Data.OleDb IntPtr gdaConnection = connection.GdaConnection; IntPtr gdaParameterList = parameters.GdaParameterList; - foreach (IntPtr gdaCommand in gdaCommands) - GdaResults.Add (libgda.gda_connection_execute_single_command (gdaConnection, gdaCommand, gdaParameterList)); + /* FIXME: split all returned resultsets into + our internal GdaResults */ + GdaResults.Add (libgda.gda_connection_execute_command ( + gdaConnection, + gdaCommand, + gdaParameterList)); dataReader = new OleDbDataReader (this); - dataReader.NextResult (); return dataReader; } - [MonoTODO] - public object ExecuteScalar () - { - throw new NotImplementedException (); - } - - [MonoTODO] - object ICloneable.Clone () - { - throw new NotImplementedException (); - } - - [MonoTODO] - IDbDataParameter IDbCommand.CreateParameter () + IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior) { - throw new NotImplementedException (); + return ExecuteReader (behavior); } - + [MonoTODO] - IDataReader IDbCommand.ExecuteReader () + public object ExecuteScalar () { throw new NotImplementedException (); } [MonoTODO] - IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior) + object ICloneable.Clone () { throw new NotImplementedException (); } diff --git a/mcs/class/System.Data/System.Data.OleDb/OleDbTransaction.cs b/mcs/class/System.Data/System.Data.OleDb/OleDbTransaction.cs index 763955ff4a1..092241cb25f 100644 --- a/mcs/class/System.Data/System.Data.OleDb/OleDbTransaction.cs +++ b/mcs/class/System.Data/System.Data.OleDb/OleDbTransaction.cs @@ -61,13 +61,13 @@ namespace System.Data.OleDb get { return connection; } } - public IsolationLevel IsolationLevel { - get { return isolationLevel; } - } - IDbConnection IDbTransaction.Connection { get { return connection; } } + + public IsolationLevel IsolationLevel { + get { return isolationLevel; } + } #endregion // Properties diff --git a/mcs/class/System.Data/System.Data.OleDb/libgda.cs b/mcs/class/System.Data/System.Data.OleDb/libgda.cs index 4c0065b7799..1d2811ff328 100644 --- a/mcs/class/System.Data/System.Data.OleDb/libgda.cs +++ b/mcs/class/System.Data/System.Data.OleDb/libgda.cs @@ -100,6 +100,9 @@ namespace System.Data.OleDb [DllImport("gda-2")] public static extern bool gda_connection_rollback_transaction (IntPtr cnc, IntPtr xaction); + [DllImport("gda-2")] + public static extern IntPtr gda_connection_execute_command (IntPtr cnc, IntPtr cmd, IntPtr parameterList); + [DllImport("gda-2")] public static extern int gda_connection_execute_non_query (IntPtr cnc, IntPtr command, IntPtr parameterList); @@ -107,6 +110,12 @@ namespace System.Data.OleDb public static extern IntPtr gda_connection_execute_single_command (IntPtr cnc, IntPtr command, IntPtr parameterList); [DllImport("gda-2")] - public static extern IntPtr gda_command_new (string text, int type, int options); + public static extern IntPtr gda_command_new (string text, GdaCommandType type, GdaCommandOptions options); + + [DllImport("gda-2")] + public static extern void gda_command_set_text (IntPtr cmd, string text); + + [DllImport("gda-2")] + public static extern void gda_command_set_command_type (IntPtr cmd, GdaCommandType type); } } -- 2.25.1