From: Rodrigo Moya Date: Fri, 16 Aug 2002 01:19:29 +0000 (-0000) Subject: 2002-08-15 Rodrigo Moya X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=58da214495a9984623d98c4c91f484bfcd5c858b;p=mono.git 2002-08-15 Rodrigo Moya * 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 --- diff --git a/mcs/class/System.Data/ChangeLog b/mcs/class/System.Data/ChangeLog index d02e77653d5..b99a3ad1b30 100644 --- a/mcs/class/System.Data/ChangeLog +++ b/mcs/class/System.Data/ChangeLog @@ -1,3 +1,16 @@ +2002-08-15 Rodrigo Moya + + * 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 * System.Data/Constraint.cs: Added helper virtual functions diff --git a/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs b/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs index 7191b72b78e..d5d304dd80a 100644 --- a/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs +++ b/mcs/class/System.Data/System.Data.OleDb/OleDbCommand.cs @@ -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; } diff --git a/mcs/class/System.Data/System.Data.OleDb/OleDbConnection.cs b/mcs/class/System.Data/System.Data.OleDb/OleDbConnection.cs index 94b8b208e6b..f544494bb4a 100644 --- a/mcs/class/System.Data/System.Data.OleDb/OleDbConnection.cs +++ b/mcs/class/System.Data/System.Data.OleDb/OleDbConnection.cs @@ -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 diff --git a/mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs b/mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs index a91c8a6759e..afe0ed673f4 100644 --- a/mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs +++ b/mcs/class/System.Data/System.Data.OleDb/OleDbDataReader.cs @@ -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; } diff --git a/mcs/class/System.Data/System.Data.OleDb/libgda.cs b/mcs/class/System.Data/System.Data.OleDb/libgda.cs index cb1afebd681..17a1f163611 100644 --- a/mcs/class/System.Data/System.Data.OleDb/libgda.cs +++ b/mcs/class/System.Data/System.Data.OleDb/libgda.cs @@ -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 { diff --git a/mcs/class/System.Data/System.Data/UniqueConstraint.cs b/mcs/class/System.Data/System.Data/UniqueConstraint.cs index 57a14eb68c6..517222df63a 100644 --- a/mcs/class/System.Data/System.Data/UniqueConstraint.cs +++ b/mcs/class/System.Data/System.Data/UniqueConstraint.cs @@ -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