2007-05-08 Adar Wesley <adarw@mainsoft.com>
authorAdar Wesley <adar@mono-cvs.ximian.com>
Tue, 8 May 2007 15:14:49 +0000 (15:14 -0000)
committerAdar Wesley <adar@mono-cvs.ximian.com>
Tue, 8 May 2007 15:14:49 +0000 (15:14 -0000)
        * DbProviderFactory.cs: minor refactoring for throwing exceptions

        * OleDbCommandBuilder.cs: added missing methods QuoteIdentifier,
        UnquoteIdentifier.

        * OleDbConnection.cs: added missing method ResetState.

        * OleDbDataReader.cs: added missing method GetData.

        * OleDbError.cs: added missing method ToString.

        * OleDbErrorCollection.cs: added missing method strongly typed
        CopyTo.

        * OleDbFactory.cs: added missing method CreatePermission.

        * OleDbParameter.cs: added missing methods ResetOleDbType,
        ResetDbType.

        * OleDbParameterCollection.cs: added missing methods strongly
        typed AddRange, IndexOf.

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

12 files changed:
mcs/class/System.Data/System.Data.Common/ChangeLog
mcs/class/System.Data/System.Data.Common/DbProviderFactory.cs
mcs/class/System.Data/System.Data.OleDb.jvm/ChangeLog
mcs/class/System.Data/System.Data.OleDb.jvm/OleDbCommandBuilder.cs
mcs/class/System.Data/System.Data.OleDb.jvm/OleDbConnection.cs
mcs/class/System.Data/System.Data.OleDb.jvm/OleDbDataReader.cs
mcs/class/System.Data/System.Data.OleDb.jvm/OleDbError.cs
mcs/class/System.Data/System.Data.OleDb.jvm/OleDbErrorCollection.cs
mcs/class/System.Data/System.Data.OleDb.jvm/OleDbFactory.cs
mcs/class/System.Data/System.Data.OleDb.jvm/OleDbParameter.cs
mcs/class/System.Data/System.Data.OleDb.jvm/OleDbParameterCollection.cs
mcs/class/System.Data/Test/System.Data/DataTableTest.cs

index a35b7606e20838f10a25e3c3b4531f0094508c35..8551a0c10226394745efc0ba92e3a3ee7539bc91 100644 (file)
@@ -1,3 +1,7 @@
+2007-05-08  Adar Wesley <adarw@mainsoft.com>
+
+       * DbProviderFactory.cs: minor refactoring for throwing exceptions
+
 2007-04-30  Marek Habersack  <mhabersack@novell.com>
 
        * DbProviderFactories.cs: throw the same exception MS.NET does.
index dd3323e245dd02dc1e11b55ff255cf4ca0daa071..8ce2a17db1eed9bc23db93b9a4268a2aaf32b493 100644 (file)
@@ -49,15 +49,14 @@ namespace System.Data.Common {
 
                #region Properties
 
-               private void ThrowNotImplementedException ()
+               private NotImplementedException CreateNotImplementedException ()
                {
-                       throw new NotImplementedException ();
+                       return new NotImplementedException ();
                }
 
                public virtual bool CanCreateDataSourceEnumerator { 
                        get {
-                               ThrowNotImplementedException ();
-                               return false; // To fix compiler error
+                               throw CreateNotImplementedException ();
                        }
                }
                #endregion // Properties
@@ -66,50 +65,42 @@ namespace System.Data.Common {
 
                public virtual DbCommand CreateCommand ()
                {
-                       ThrowNotImplementedException ();
-                       return null; // To fix compiler error
+                       throw CreateNotImplementedException ();
                }
 
                public virtual DbCommandBuilder CreateCommandBuilder ()
                {
-                       ThrowNotImplementedException ();
-                       return null; // To fix compiler error
+                       throw CreateNotImplementedException ();
                }
 
                public virtual DbConnection CreateConnection ()
                {
-                       ThrowNotImplementedException ();
-                       return null; // To fix compiler error
+                       throw CreateNotImplementedException ();
                }
 
                public virtual DbDataAdapter CreateDataAdapter ()
                {
-                       ThrowNotImplementedException ();
-                       return null; // To fix compiler error
+                       throw CreateNotImplementedException ();
                }
 
                public virtual DbDataSourceEnumerator CreateDataSourceEnumerator ()
                {
-                       ThrowNotImplementedException ();
-                       return null; // To fix compiler error
+                       throw CreateNotImplementedException ();
                }
 
                public virtual DbParameter CreateParameter ()
                {
-                       ThrowNotImplementedException ();
-                       return null; // To fix compiler error
+                       throw CreateNotImplementedException ();
                }
 
                public virtual CodeAccessPermission CreatePermission (PermissionState state)
                {
-                       ThrowNotImplementedException ();
-                       return null; // To fix compiler error
+                       throw CreateNotImplementedException ();
                }
 
                public virtual DbConnectionStringBuilder CreateConnectionStringBuilder ()
                {
-                       ThrowNotImplementedException ();
-                       return null; // To fix compiler error
+                       throw CreateNotImplementedException ();
                }
                #endregion // Methods
        }
index b7f8fe2127ef539546fd0fd96884f6a008ab0edf..6daabb826e3ac77987bc641b5a2883e6897c50c8 100644 (file)
@@ -1,3 +1,25 @@
+2007-05-08 Adar Wesley <adarw@mainsoft.com>
+
+       * OleDbCommandBuilder.cs: added missing methods QuoteIdentifier,
+       UnquoteIdentifier.
+
+       * OleDbConnection.cs: added missing method ResetState.
+
+       * OleDbDataReader.cs: added missing method GetData.
+
+       * OleDbError.cs: added missing method ToString.
+
+       * OleDbErrorCollection.cs: added missing method strongly typed
+       CopyTo.
+
+       * OleDbFactory.cs: added missing method CreatePermission.
+
+       * OleDbParameter.cs: added missing methods ResetOleDbType,
+       ResetDbType.
+
+       * OleDbParameterCollection.cs: added missing methods strongly
+       typed AddRange, IndexOf.
+
 2007-05-01 Adar Wesley <adarw@mainsoft.com>
 
        * OleDbCommandBuilder.cs: Fixed typo and called base implementation
index 9f4ebaaa83cd6f95dab0dda13c93c2551955ad1d..1ebe4fbacfc8951b0f0a3c22706ea597405c3986 100644 (file)
@@ -1,13 +1,13 @@
-//\r
-// System.Data.OleDb.OleDbCommandBuilder\r
-//\r
-// Author:\r
-//   Rodrigo Moya (rodrigo@ximian.com)\r
-//   Tim Coleman (tim@timcoleman.com)\r
+//
+// System.Data.OleDb.OleDbCommandBuilder
+//
+// Author:
+//   Rodrigo Moya (rodrigo@ximian.com)
+//   Tim Coleman (tim@timcoleman.com)
 //     Konstantin Triger <kostat@mainsoft.com>
-//     Boris Kirzner <borisk@mainsoft.com>\r
-//\r
-// Copyright (C) Rodrigo Moya, 2002\r
+//     Boris Kirzner <borisk@mainsoft.com>
+//
+// Copyright (C) Rodrigo Moya, 2002
 // Copyright (C) Tim Coleman, 2002     
 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
 //
 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//\r
-\r
-\r
-using System.ComponentModel;\r
-using System.Data;\r
-using System.Data.Common;\r
-using System.Data.ProviderBase;\r
-\r
-namespace System.Data.OleDb\r
-{\r
-       /// <summary>\r
-       /// Provides a means of automatically generating single-table commands used to reconcile changes made to a DataSet with the associated database. This class cannot be inherited.\r
-       /// </summary>\r
-       public sealed class OleDbCommandBuilder : AbstractDbCommandBuilder\r
-       {\r
-               #region Fields\r
-\r
-               OleDbDataAdapter adapter;\r
-               string quotePrefix;\r
-               string quoteSuffix;\r
-\r
-               #endregion // Fields\r
-\r
-               #region Constructors\r
-               \r
-               public OleDbCommandBuilder ()\r
-               {\r
-                       adapter = null;\r
-                       quotePrefix = String.Empty;\r
-                       quoteSuffix = String.Empty;\r
-               }\r
-\r
-               public OleDbCommandBuilder (OleDbDataAdapter adapter) \r
-                       : this ()\r
-               {\r
-                       this.adapter = adapter;\r
-               }\r
-\r
-               #endregion // Constructors\r
-\r
-               #region Properties\r
-\r
-               public OleDbDataAdapter DataAdapter {\r
-                       get {\r
-                               return adapter;\r
-                       }\r
-                       set {\r
-                               adapter = value;\r
-                       }\r
-               }\r
-\r
-               public string QuotePrefix {\r
-                       get {\r
-                               return quotePrefix;\r
-                       }\r
-                       set {\r
-                               quotePrefix = value;\r
-                       }\r
-               }\r
-\r
-               public string QuoteSuffix {\r
-                       get {\r
-                               return quoteSuffix;\r
-                       }\r
-                       set {\r
-                               quoteSuffix = value;\r
-                       }\r
-               }\r
-\r
-               #endregion // Properties\r
-\r
-               #region Methods\r
-\r
-               public static void DeriveParameters (OleDbCommand command) \r
-               {\r
-                       DeriveParameters((AbstractDbCommand)command);\r
-               }\r
-\r
-               protected override void Dispose (bool disposing) \r
-               {\r
-                       base.Dispose ();        \r
-               }\r
-\r
-               public new OleDbCommand GetDeleteCommand ()\r
-               {\r
-                       return (OleDbCommand) base.GetDeleteCommand ();\r
-               }\r
-\r
-               public new OleDbCommand GetInsertCommand ()\r
-               {\r
-                       return (OleDbCommand) base.GetInsertCommand ();\r
-               }\r
-\r
-               public new OleDbCommand GetUpdateCommand ()\r
-               {\r
-                       return (OleDbCommand) base.GetUpdateCommand ();\r
-               }\r
-\r
-               [MonoTODO]\r
-               public void RefreshSchema ()\r
-               {\r
-                       throw new NotImplementedException ();\r
-               }\r
-\r
-               #endregion // Methods\r
-       }\r
-}\r
+//
+
+
+using System.ComponentModel;
+using System.Data;
+using System.Data.Common;
+using System.Data.ProviderBase;
+
+namespace System.Data.OleDb
+{
+       /// <summary>
+       /// Provides a means of automatically generating single-table commands used to reconcile changes made to a DataSet with the associated database. This class cannot be inherited.
+       /// </summary>
+       public sealed class OleDbCommandBuilder : AbstractDbCommandBuilder
+       {
+               #region Fields
+
+               OleDbDataAdapter adapter;
+               string quotePrefix;
+               string quoteSuffix;
+
+               #endregion // Fields
+
+               #region Constructors
+               
+               public OleDbCommandBuilder ()
+               {
+                       adapter = null;
+                       quotePrefix = String.Empty;
+                       quoteSuffix = String.Empty;
+               }
+
+               public OleDbCommandBuilder (OleDbDataAdapter adapter) 
+                       : this ()
+               {
+                       this.adapter = adapter;
+               }
+
+               #endregion // Constructors
+
+               #region Properties
+
+               public OleDbDataAdapter DataAdapter {
+                       get {
+                               return adapter;
+                       }
+                       set {
+                               adapter = value;
+                       }
+               }
+
+               public string QuotePrefix {
+                       get {
+                               return quotePrefix;
+                       }
+                       set {
+                               quotePrefix = value;
+                       }
+               }
+
+               public string QuoteSuffix {
+                       get {
+                               return quoteSuffix;
+                       }
+                       set {
+                               quoteSuffix = value;
+                       }
+               }
+
+               #endregion // Properties
+
+               #region Methods
+
+               public static void DeriveParameters (OleDbCommand command) 
+               {
+                       DeriveParameters((AbstractDbCommand)command);
+               }
+
+               protected override void Dispose (bool disposing) 
+               {
+                       base.Dispose ();        
+               }
+
+               public new OleDbCommand GetDeleteCommand ()
+               {
+                       return (OleDbCommand) base.GetDeleteCommand ();
+               }
+
+               public new OleDbCommand GetInsertCommand ()
+               {
+                       return (OleDbCommand) base.GetInsertCommand ();
+               }
+
+               public new OleDbCommand GetUpdateCommand ()
+               {
+                       return (OleDbCommand) base.GetUpdateCommand ();
+               }
+
+               [MonoTODO]
+               public void RefreshSchema ()
+               {
+                       throw new NotImplementedException ();
+               }
+
+#if NET_2_0
+
+               [MonoNotSupported("")]
+               public string QuoteIdentifier (string unquotedIdentifier, OleDbConnection connection) 
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoNotSupported ("")]
+               public string UnquoteIdentifier (string quotedIdentifier, OleDbConnection connection)
+               {
+                       throw new NotImplementedException ();
+               }
+
+#endif
+               #endregion // Methods
+       }
+}
index fcd11512b1761bb2ec18f6fc93f06013aa331e30..6c96afb556f610a19533c0523ff503ca03e5bbeb 100644 (file)
-//\r
-// System.Data.OleDb.OleDbConnection\r
-//\r
-// Authors:\r
-//     Konstantin Triger <kostat@mainsoft.com>\r
-//     Boris Kirzner <borisk@mainsoft.com>\r
-//     \r
-// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)\r
-//\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-\r
-\r
-using System.Data;\r
-using System.Data.Common;\r
-using System.Collections;\r
-using System.Data.ProviderBase;\r
-using System.Globalization;\r
-\r
-using java.sql;\r
-\r
-using System.Configuration;\r
-using Mainsoft.Data.Configuration;\r
-using Mainsoft.Data.Jdbc.Providers;\r
-\r
-namespace System.Data.OleDb\r
-{\r
-       public sealed class OleDbConnection : AbstractDBConnection {\r
-\r
-               #region Events\r
-\r
-               public event OleDbInfoMessageEventHandler InfoMessage;\r
-\r
-               #endregion // Events\r
-               \r
-               #region Constructors\r
-\r
-               public OleDbConnection() : this(null) {\r
-               }\r
-\r
-               public OleDbConnection(String connectionString) : base(connectionString) {                      \r
-               }\r
-\r
-               #endregion // Constructors\r
-\r
-               #region Properties\r
-\r
-               public String Provider {\r
-                       get {\r
-                               IDictionary conDict = ConnectionStringBuilder;\r
-                               string provider = (string)conDict["Provider"];\r
-                               if (provider == null || provider.Length == 0)\r
-                                       throw ExceptionHelper.OleDbNoProviderSpecified();\r
-\r
-                               return provider;\r
-                       }\r
-               }\r
-\r
-               protected override IConnectionProvider GetConnectionProvider() {\r
-                       IDictionary conProviderDict = ConnectionStringDictionary.Parse(ConnectionString);\r
-                       string jdbcUrl = (string)conProviderDict["JdbcUrl"];\r
-                       if (jdbcUrl == null) {\r
-                               string provider = (string)conProviderDict["Provider"];\r
-                               if (provider != null)\r
-                                       return GetConnectionProvider("Mainsoft.Data.Configuration/OleDbProviders", provider);\r
-                       }\r
-\r
-                       return new GenericProvider (conProviderDict);\r
-               }\r
-\r
-               #endregion // Properties\r
-\r
-               #region Methods\r
-\r
-               public new OleDbTransaction BeginTransaction(IsolationLevel level)\r
-               {\r
-                       return new OleDbTransaction(level, this);\r
-               }\r
-\r
-               public new OleDbTransaction BeginTransaction()\r
-               {\r
-                       return BeginTransaction(IsolationLevel.ReadCommitted);\r
-               }\r
-\r
-               public new OleDbCommand CreateCommand()\r
-               {\r
-                       return new OleDbCommand(this);\r
-               }\r
-\r
-               protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) {\r
-                       return BeginTransaction();\r
-               }\r
-\r
-               protected override DbCommand CreateDbCommand() {\r
-                       return CreateCommand();\r
-               }\r
-\r
-               protected sealed override SystemException CreateException(SQLException e)\r
-               {\r
-                       return new OleDbException(e,this);              \r
-               }\r
-\r
-               protected sealed override SystemException CreateException(string message)\r
-               {\r
-                       return new OleDbException(message, null, this); \r
-               }\r
-\r
-               [MonoTODO]\r
-               public DataTable GetOleDbSchemaTable (Guid schema, object[] restrictions)\r
-               {\r
-                       if (State != ConnectionState.Open)\r
-                               throw ExceptionHelper.ConnectionNotOpened("GetOleDbSchemaTable", State.ToString());\r
-\r
-                       try {\r
-\r
-                               string[] fixedRestrictions = new string[4];\r
-                               if (restrictions != null) {\r
-                                       if (restrictions.Length > 4)\r
-                                               throw new OleDbException("The parameter is incorrect", null, this);\r
-\r
-                                       for (int i = 0, count = restrictions.Length; i < count; i ++) {\r
-                                               if (restrictions[i] != null) {\r
-                                                       if (!(restrictions[i] is string))\r
-                                                               throw new OleDbException("The parameter is incorrect", null, this);\r
-\r
-                                                       fixedRestrictions[i] = (string)restrictions[i];\r
-                                               }\r
-                                       }\r
-                               }\r
-\r
-                               DataTable schemaTable = new DataTable("Tables");\r
-                               schemaTable.Columns.Add("TABLE_CATALOG");\r
-                               schemaTable.Columns.Add("TABLE_SCHEMA");\r
-                               schemaTable.Columns.Add("TABLE_NAME");\r
-                               schemaTable.Columns.Add("TABLE_TYPE");\r
-                               schemaTable.Columns.Add("TABLE_GUID");\r
-                               schemaTable.Columns.Add("DESCRIPTION");\r
-                               schemaTable.Columns.Add("TABLE_PROPID");\r
-                               schemaTable.Columns.Add("DATE_CREATED");\r
-                               schemaTable.Columns.Add("DATE_MODIFIED");\r
-\r
-                               java.sql.ResultSet tableRes = JdbcConnection.getMetaData().getTables(\r
-                                       fixedRestrictions[0],\r
-                                       fixedRestrictions[1],\r
-                                       fixedRestrictions[2],\r
-                                       new string[]{fixedRestrictions[3]});\r
-\r
-                               try {\r
-                                       while(tableRes.next()) {\r
-                                               DataRow row = schemaTable.NewRow();\r
-                                               row["TABLE_CATALOG"] = tableRes.getString("TABLE_CAT");\r
-                                               row["TABLE_SCHEMA"] = tableRes.getString("TABLE_SCHEM");\r
-                                               row["TABLE_NAME"] = tableRes.getString("TABLE_NAME");\r
-                                               row["TABLE_TYPE"] = tableRes.getString("TABLE_TYPE");\r
-                                               row["DESCRIPTION"] = tableRes.getString("REMARKS");\r
-                \r
-                                               schemaTable.Rows.Add(row);\r
-                                       }\r
-                               }\r
-                               finally {\r
-                                       tableRes.close();\r
-                               }\r
-\r
-                               return schemaTable;\r
-                       }\r
-                       catch (SQLException e) {\r
-                               throw CreateException(e);\r
-                       }\r
-               }\r
-\r
-               public static void ReleaseObjectPool()\r
-               {\r
-                       // since we're using connection pool from app servet, this is by design\r
-                       //throw new NotImplementedException();\r
-               }\r
-\r
-               protected internal sealed override void OnSqlWarning(SQLWarning warning)\r
-               {\r
-                       OleDbErrorCollection col = new OleDbErrorCollection(warning, this);\r
-                       OnOleDbInfoMessage(new OleDbInfoMessageEventArgs(col));\r
-               }\r
-\r
-               private void OnOleDbInfoMessage (OleDbInfoMessageEventArgs value)\r
-               {\r
-                       if (InfoMessage != null) {\r
-                               InfoMessage (this, value);\r
-                       }\r
-               }\r
-\r
-               #endregion // Methods\r
-\r
-       }\r
-}\r
+//
+// System.Data.OleDb.OleDbConnection
+//
+// Authors:
+//     Konstantin Triger <kostat@mainsoft.com>
+//     Boris Kirzner <borisk@mainsoft.com>
+//     
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+
+using System.Data;
+using System.Data.Common;
+using System.Collections;
+using System.Data.ProviderBase;
+using System.Globalization;
+
+using java.sql;
+
+using System.Configuration;
+using Mainsoft.Data.Configuration;
+using Mainsoft.Data.Jdbc.Providers;
+
+namespace System.Data.OleDb
+{
+       public sealed class OleDbConnection : AbstractDBConnection {
+
+               #region Events
+
+               public event OleDbInfoMessageEventHandler InfoMessage;
+
+               #endregion // Events
+               
+               #region Constructors
+
+               public OleDbConnection() : this(null) {
+               }
+
+               public OleDbConnection(String connectionString) : base(connectionString) {                      
+               }
+
+               #endregion // Constructors
+
+               #region Properties
+
+               public String Provider {
+                       get {
+                               IDictionary conDict = ConnectionStringBuilder;
+                               string provider = (string)conDict["Provider"];
+                               if (provider == null || provider.Length == 0)
+                                       throw ExceptionHelper.OleDbNoProviderSpecified();
+
+                               return provider;
+                       }
+               }
+
+               protected override IConnectionProvider GetConnectionProvider() {
+                       IDictionary conProviderDict = ConnectionStringDictionary.Parse(ConnectionString);
+                       string jdbcUrl = (string)conProviderDict["JdbcUrl"];
+                       if (jdbcUrl == null) {
+                               string provider = (string)conProviderDict["Provider"];
+                               if (provider != null)
+                                       return GetConnectionProvider("Mainsoft.Data.Configuration/OleDbProviders", provider);
+                       }
+
+                       return new GenericProvider (conProviderDict);
+               }
+
+               #endregion // Properties
+
+               #region Methods
+
+               public new OleDbTransaction BeginTransaction(IsolationLevel level)
+               {
+                       return new OleDbTransaction(level, this);
+               }
+
+               public new OleDbTransaction BeginTransaction()
+               {
+                       return BeginTransaction(IsolationLevel.ReadCommitted);
+               }
+
+               public new OleDbCommand CreateCommand()
+               {
+                       return new OleDbCommand(this);
+               }
+
+               protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) {
+                       return BeginTransaction();
+               }
+
+               protected override DbCommand CreateDbCommand() {
+                       return CreateCommand();
+               }
+
+               protected sealed override SystemException CreateException(SQLException e)
+               {
+                       return new OleDbException(e,this);              
+               }
+
+               protected sealed override SystemException CreateException(string message)
+               {
+                       return new OleDbException(message, null, this); 
+               }
+
+               [MonoTODO]
+               public DataTable GetOleDbSchemaTable (Guid schema, object[] restrictions)
+               {
+                       if (State != ConnectionState.Open)
+                               throw ExceptionHelper.ConnectionNotOpened("GetOleDbSchemaTable", State.ToString());
+
+                       try {
+
+                               string[] fixedRestrictions = new string[4];
+                               if (restrictions != null) {
+                                       if (restrictions.Length > 4)
+                                               throw new OleDbException("The parameter is incorrect", null, this);
+
+                                       for (int i = 0, count = restrictions.Length; i < count; i ++) {
+                                               if (restrictions[i] != null) {
+                                                       if (!(restrictions[i] is string))
+                                                               throw new OleDbException("The parameter is incorrect", null, this);
+
+                                                       fixedRestrictions[i] = (string)restrictions[i];
+                                               }
+                                       }
+                               }
+
+                               DataTable schemaTable = new DataTable("Tables");
+                               schemaTable.Columns.Add("TABLE_CATALOG");
+                               schemaTable.Columns.Add("TABLE_SCHEMA");
+                               schemaTable.Columns.Add("TABLE_NAME");
+                               schemaTable.Columns.Add("TABLE_TYPE");
+                               schemaTable.Columns.Add("TABLE_GUID");
+                               schemaTable.Columns.Add("DESCRIPTION");
+                               schemaTable.Columns.Add("TABLE_PROPID");
+                               schemaTable.Columns.Add("DATE_CREATED");
+                               schemaTable.Columns.Add("DATE_MODIFIED");
+
+                               java.sql.ResultSet tableRes = JdbcConnection.getMetaData().getTables(
+                                       fixedRestrictions[0],
+                                       fixedRestrictions[1],
+                                       fixedRestrictions[2],
+                                       new string[]{fixedRestrictions[3]});
+
+                               try {
+                                       while(tableRes.next()) {
+                                               DataRow row = schemaTable.NewRow();
+                                               row["TABLE_CATALOG"] = tableRes.getString("TABLE_CAT");
+                                               row["TABLE_SCHEMA"] = tableRes.getString("TABLE_SCHEM");
+                                               row["TABLE_NAME"] = tableRes.getString("TABLE_NAME");
+                                               row["TABLE_TYPE"] = tableRes.getString("TABLE_TYPE");
+                                               row["DESCRIPTION"] = tableRes.getString("REMARKS");
+                
+                                               schemaTable.Rows.Add(row);
+                                       }
+                               }
+                               finally {
+                                       tableRes.close();
+                               }
+
+                               return schemaTable;
+                       }
+                       catch (SQLException e) {
+                               throw CreateException(e);
+                       }
+               }
+
+               public static void ReleaseObjectPool()
+               {
+                       // since we're using connection pool from app servet, this is by design
+                       //throw new NotImplementedException();
+               }
+
+#if NET_2_0
+               [MonoLimitation ("Empty implementation since State relies on java.sql.Connection.State always returning the correct state")]
+               public void ResetState () 
+               {
+               }
+
+#endif
+
+               protected internal sealed override void OnSqlWarning(SQLWarning warning)
+               {
+                       OleDbErrorCollection col = new OleDbErrorCollection(warning, this);
+                       OnOleDbInfoMessage(new OleDbInfoMessageEventArgs(col));
+               }
+
+               private void OnOleDbInfoMessage (OleDbInfoMessageEventArgs value)
+               {
+                       if (InfoMessage != null) {
+                               InfoMessage (this, value);
+                       }
+               }
+
+               #endregion // Methods
+
+       }
+}
index 24d9dbebc40cc583a9b746d09377e6562becdf1b..554298c4693724011c673000e6e72c4f777f1028 100644 (file)
@@ -1,10 +1,10 @@
-//\r
-// System.Data.OleDb.OleDbDataReader\r
-//\r
+//
+// System.Data.OleDb.OleDbDataReader
+//
 // Authors:
 //     Konstantin Triger <kostat@mainsoft.com>
-//     Boris Kirzner <borisk@mainsoft.com>\r
-//\r
+//     Boris Kirzner <borisk@mainsoft.com>
+//
 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
 //
 
 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//\r
-\r
-using System.Data.Common;\r
-using System.Data.ProviderBase;\r
-\r
-using java.sql;\r
-\r
-namespace System.Data.OleDb\r
-{\r
-       public sealed class OleDbDataReader : AbstractDataReader\r
-       {\r
-               #region Fields\r
-\r
-               #endregion // Fields\r
-\r
-               #region Constructors\r
-\r
-               internal OleDbDataReader(OleDbCommand command) : base(command)\r
-               {\r
-               }\r
-\r
-               #endregion // Constructors\r
-\r
-               #region Methods\r
-\r
-               protected sealed override SystemException CreateException(string message, SQLException e)\r
-               {\r
-                       return new OleDbException(message,e, (OleDbConnection)_command.Connection);             \r
-               }\r
-\r
-               protected sealed override SystemException CreateException(java.io.IOException e)\r
-               {\r
-                       return new OleDbException(e, (OleDbConnection)_command.Connection);             \r
-               }\r
-\r
-               public override String GetDataTypeName(int columnIndex)\r
-               {\r
-                       try {\r
-                               string jdbcTypeName = Results.getMetaData().getColumnTypeName(columnIndex + 1);\r
-                               \r
-                               return OleDbConvert.JdbcTypeNameToDbTypeName(jdbcTypeName);\r
-                       }\r
-                       catch (SQLException e) {\r
-                               throw CreateException(e);\r
-                       }\r
-               }\r
-\r
+//
+
+using System.Data.Common;
+using System.Data.ProviderBase;
+
+using java.sql;
+
+namespace System.Data.OleDb
+{
+       public sealed class OleDbDataReader : AbstractDataReader
+       {
+               #region Fields
+
+               #endregion // Fields
+
+               #region Constructors
+
+               internal OleDbDataReader(OleDbCommand command) : base(command)
+               {
+               }
+
+               #endregion // Constructors
+
+               #region Methods
+
+               protected sealed override SystemException CreateException(string message, SQLException e)
+               {
+                       return new OleDbException(message,e, (OleDbConnection)_command.Connection);             
+               }
+
+               protected sealed override SystemException CreateException(java.io.IOException e)
+               {
+                       return new OleDbException(e, (OleDbConnection)_command.Connection);             
+               }
+
+               public override String GetDataTypeName(int columnIndex)
+               {
+                       try {
+                               string jdbcTypeName = Results.getMetaData().getColumnTypeName(columnIndex + 1);
+                               
+                               return OleDbConvert.JdbcTypeNameToDbTypeName(jdbcTypeName);
+                       }
+                       catch (SQLException e) {
+                               throw CreateException(e);
+                       }
+               }
+
                protected override int GetProviderType(int jdbcType)
                {
                        return (int)OleDbConvert.JdbcTypeToOleDbType(jdbcType);   
-               }\r
-\r
-               #endregion // Methods\r
-       }\r
+               }
+
+               [MonoNotSupported("")]
+               public OleDbDataReader GetData (int ordinal)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               #endregion // Methods
+       }
 }
\ No newline at end of file
index 4249959c651ce392321aa2b098834dbded9932a1..f46680d629a3b267e836f778ea8ce26c27137dbf 100644 (file)
@@ -1,5 +1,5 @@
-//\r
-// System.Data.OleDb.OleDbError\r
+//
+// System.Data.OleDb.OleDbError
 //
 // Authors:
 //     Konstantin Triger <kostat@mainsoft.com>
 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//\r
-\r
-\r
-namespace System.Data.OleDb\r
-{\r
-       using java.sql;\r
-       using System.Data.Common;\r
-       using System.Data.ProviderBase;\r
-\r
-       [Serializable]\r
-    public sealed class OleDbError : AbstractDbError\r
-    {\r
-\r
-               internal OleDbError(SQLException e, AbstractDBConnection connection) : base(e, connection) {\r
-               }\r
-    \r
-        public String Message\r
-        {\r
-            get\r
-            {\r
-                return DbMessage;\r
-            }\r
-        }\r
-    \r
-        public int NativeError\r
-        {\r
-            get\r
-            {\r
-                return DbErrorCode;\r
-            }\r
-        }\r
-    \r
-        public String Source\r
-        {\r
-            get\r
-            {\r
-                return DbSource;\r
-            }\r
-        }\r
-    \r
-        public String SQLState\r
-        {\r
-            get\r
-            {\r
-                return DbSQLState;\r
-            }\r
-        }\r
-    }\r
+//
+
+
+namespace System.Data.OleDb
+{
+       using java.sql;
+       using System.Data.Common;
+       using System.Data.ProviderBase;
+
+       [Serializable]
+    public sealed class OleDbError : AbstractDbError
+    {
+
+               internal OleDbError(SQLException e, AbstractDBConnection connection) : base(e, connection) {
+               }
+    
+        public String Message
+        {
+            get
+            {
+                return DbMessage;
+            }
+        }
+    
+        public int NativeError
+        {
+            get
+            {
+                return DbErrorCode;
+            }
+        }
+    
+        public String Source
+        {
+            get
+            {
+                return DbSource;
+            }
+        }
+    
+        public String SQLState
+        {
+            get
+            {
+                return DbSQLState;
+            }
+        }
+
+               public override string ToString () 
+               {
+                       string toStr;
+
+                       toStr = String.Format("OleDbError: {0}. {1}", Message, _e.StackTrace);
+                       return toStr;
+
+               }
+    }
 }
\ No newline at end of file
index 5635a8b127995b97a7af8ede000da0d5557c40d5..f1c96c20175420b51781ba6e39d3733683f96606 100644 (file)
@@ -1,5 +1,5 @@
-//\r
-// System.Data.OleDb.OleDbErrorCollection\r
+//
+// System.Data.OleDb.OleDbErrorCollection
 //
 // Authors:
 //     Konstantin Triger <kostat@mainsoft.com>
 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//\r
-\r
-\r
-namespace System.Data.OleDb\r
-{\r
-\r
-\r
-    using System.Collections;\r
-       using java.sql;\r
-       using System.Data.Common;\r
-       using System.Data.ProviderBase;\r
-\r
-       [Serializable]\r
-    public sealed class OleDbErrorCollection : AbstractDbErrorCollection\r
-    {\r
-               internal OleDbErrorCollection(SQLException e, AbstractDBConnection connection) : base(e, connection) {\r
-               }\r
-        /**\r
-         * Gets the error at the specified index.\r
-         *\r
-         * @param index of the error\r
-         * @return Error on specified index\r
-         */\r
-        public OleDbError this[int index]\r
-        {\r
-            get\r
-            {\r
-                return (OleDbError)GetDbItem(index);\r
-            }\r
-        }\r
-\r
-               protected override AbstractDbError CreateDbError(SQLException e, AbstractDBConnection connection) {\r
-                       return new OleDbError(e, connection);\r
-               }\r
-\r
-    }\r
+//
+
+
+namespace System.Data.OleDb
+{
+
+
+    using System.Collections;
+       using java.sql;
+       using System.Data.Common;
+       using System.Data.ProviderBase;
+
+       [Serializable]
+    public sealed class OleDbErrorCollection : AbstractDbErrorCollection
+    {
+               internal OleDbErrorCollection(SQLException e, AbstractDBConnection connection) : base(e, connection) {
+               }
+        /**
+         * Gets the error at the specified index.
+         *
+         * @param index of the error
+         * @return Error on specified index
+         */
+        public OleDbError this[int index]
+        {
+            get
+            {
+                return (OleDbError)GetDbItem(index);
+            }
+        }
+
+#if NET_2_0
+               public void CopyTo (OleDbError [] array, int index)
+               {
+                       base.CopyTo (array, index);
+               }
+
+#endif
+
+               protected override AbstractDbError CreateDbError(SQLException e, AbstractDBConnection connection) {
+                       return new OleDbError(e, connection);
+               }
+
+    }
 }
\ No newline at end of file
index 7407944159da05be29ead4d86d48cc09642a5ee2..a312b0eecb7a2cb933497b50aacc7c4123594ae0 100644 (file)
@@ -32,6 +32,8 @@ namespace System.Data.OleDb
 {
        using System.Data;
        using System.Data.Common;
+       using System.Security;
+       using System.Security.Permissions;
 
        public sealed class OleDbFactory : DbProviderFactory
        {
@@ -74,6 +76,12 @@ namespace System.Data.OleDb
                        return (DbDataAdapter) new OleDbDataAdapter ();
                }
 
+               [MonoLimitation("Code Access Security is not supported")]
+               public override CodeAccessPermission CreatePermission (PermissionState state) 
+               {
+                       return new OleDbPermission (state);
+               }
+
                [MonoTODO]
                public override DbDataSourceEnumerator CreateDataSourceEnumerator ()
                {
index 08fd46d2b38562dbf384a8414998bde98658e2e6..71c7403501ae428968ff550ff9bd741b0ba314e4 100644 (file)
@@ -1,5 +1,5 @@
-//\r
-// System.Data.OleDb.OleDbParameter\r
+//
+// System.Data.OleDb.OleDbParameter
 //
 // Authors:
 //     Konstantin Triger <kostat@mainsoft.com>
 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//\r
-\r
-\r
-using System;\r
-using System.Text;\r
-using System.Data;\r
-using System.Data.Common;\r
-using System.Data.ProviderBase;\r
-\r
-using java.sql;\r
-using java.lang;\r
-using System.Globalization;\r
-\r
-namespace System.Data.OleDb\r
-{\r
-    public sealed class OleDbParameter : AbstractDbParameter\r
-    {\r
-\r
-               #region Fields\r
-\r
-        private OleDbType _oleDbType = OleDbType.VarWChar;\r
-               private bool _isOracleRefCursor = false;\r
-\r
-               #endregion // Fields\r
-    \r
-               #region Constructors\r
-\r
-        public OleDbParameter()\r
-        {\r
-        }\r
-    \r
-        public OleDbParameter(String parameterName, Object value)\r
-                       : this (parameterName, OleDbType.VarWChar, 0, ParameterDirection.Input,\r
-                                       false, 0, 0, String.Empty, DataRowVersion.Current, value)\r
-        {\r
-                       IsDbTypeSet = false;\r
-        }\r
-    \r
-        public OleDbParameter(String parameterName, OleDbType dbType)\r
-                       : this (parameterName, dbType, 0, ParameterDirection.Input,\r
-                                       false, 0, 0, String.Empty, DataRowVersion.Current, null)\r
-        {\r
-        }\r
-    \r
-        public OleDbParameter(String parameterName, OleDbType dbType, int size)\r
-                       : this (parameterName, dbType, size, ParameterDirection.Input,\r
-                                       false, 0, 0, String.Empty, DataRowVersion.Current, null)\r
-        {\r
-        }\r
-    \r
-        public OleDbParameter(String parameterName, OleDbType dbType, int size,\r
-            String sourceColumn)\r
-                       : this (parameterName, dbType, size, ParameterDirection.Input,\r
-                                       false, 0, 0, sourceColumn, DataRowVersion.Current, null)\r
-        {\r
-        }\r
-    \r
-        \r
-        public OleDbParameter(String parameterName, \r
-                                                       OleDbType dbType, \r
-                                                       int size,\r
-                                                       ParameterDirection direction, \r
-                                                       bool isNullable,\r
-                                                       byte precision, \r
-                                                       byte scale, \r
-                                                       String sourceColumn,\r
-                                                       DataRowVersion sourceVersion, \r
-                                                       Object value)\r
-        {\r
-            ParameterName = parameterName;\r
-            OleDbType = dbType;\r
-            Size = size;\r
-            Direction = direction;\r
-            IsNullable = isNullable;\r
-            Precision = precision;\r
-            Scale = scale;\r
-            SourceColumn = sourceColumn;\r
-            SourceVersion = sourceVersion;\r
-            Value = value;\r
-        }\r
-\r
-               #endregion // Constructors\r
-\r
-               #region Properties\r
-\r
-               public override DbType DbType\r
-        {\r
-            get { return OleDbConvert.OleDbTypeToDbType(_oleDbType); }           \r
-                       set { OleDbType = OleDbConvert.DbTypeToOleDbType(value); }\r
-        }                \r
-        \r
-        public OleDbType OleDbType\r
-        {\r
-            get { return _oleDbType; }            \r
-                       set {\r
-                _oleDbType = value;\r
-                               IsDbTypeSet = true;\r
-            }\r
-        }    \r
-\r
-#if NET_2_0\r
+//
+
+
+using System;
+using System.Text;
+using System.Data;
+using System.Data.Common;
+using System.Data.ProviderBase;
+
+using java.sql;
+using java.lang;
+using System.Globalization;
+
+namespace System.Data.OleDb
+{
+    public sealed class OleDbParameter : AbstractDbParameter
+    {
+
+               #region Fields
+
+        private OleDbType _oleDbType = OleDbType.VarWChar;
+               private bool _isOracleRefCursor = false;
+
+               #endregion // Fields
+    
+               #region Constructors
+
+        public OleDbParameter()
+        {
+        }
+    
+        public OleDbParameter(String parameterName, Object value)
+                       : this (parameterName, OleDbType.VarWChar, 0, ParameterDirection.Input,
+                                       false, 0, 0, String.Empty, DataRowVersion.Current, value)
+        {
+                       IsDbTypeSet = false;
+        }
+    
+        public OleDbParameter(String parameterName, OleDbType dbType)
+                       : this (parameterName, dbType, 0, ParameterDirection.Input,
+                                       false, 0, 0, String.Empty, DataRowVersion.Current, null)
+        {
+        }
+    
+        public OleDbParameter(String parameterName, OleDbType dbType, int size)
+                       : this (parameterName, dbType, size, ParameterDirection.Input,
+                                       false, 0, 0, String.Empty, DataRowVersion.Current, null)
+        {
+        }
+    
+        public OleDbParameter(String parameterName, OleDbType dbType, int size,
+            String sourceColumn)
+                       : this (parameterName, dbType, size, ParameterDirection.Input,
+                                       false, 0, 0, sourceColumn, DataRowVersion.Current, null)
+        {
+        }
+    
+        
+        public OleDbParameter(String parameterName, 
+                                                       OleDbType dbType, 
+                                                       int size,
+                                                       ParameterDirection direction, 
+                                                       bool isNullable,
+                                                       byte precision, 
+                                                       byte scale, 
+                                                       String sourceColumn,
+                                                       DataRowVersion sourceVersion, 
+                                                       Object value)
+        {
+            ParameterName = parameterName;
+            OleDbType = dbType;
+            Size = size;
+            Direction = direction;
+            IsNullable = isNullable;
+            Precision = precision;
+            Scale = scale;
+            SourceColumn = sourceColumn;
+            SourceVersion = sourceVersion;
+            Value = value;
+        }
+
+               #endregion // Constructors
+
+               #region Properties
+
+               public override DbType DbType
+        {
+            get { return OleDbConvert.OleDbTypeToDbType(_oleDbType); }           
+                       set { OleDbType = OleDbConvert.DbTypeToOleDbType(value); }
+        }                
+        
+        public OleDbType OleDbType
+        {
+            get { return _oleDbType; }            
+                       set {
+                _oleDbType = value;
+                               IsDbTypeSet = true;
+            }
+        }    
+
+#if NET_2_0
                public new byte Precision 
                { 
-                       get { return base.Precision; }\r
+                       get { return base.Precision; }
                        set { base.Precision = value; } 
                }
 
                public new byte Scale 
                { 
-                       get { return base.Scale; }\r
+                       get { return base.Scale; }
                        set { base.Scale = value; } 
-               }\r
-#endif\r
-    \r
-        public new Object Value\r
-        {\r
-            get { return base.Value; }\r
-            set {\r
-                if (!IsDbTypeSet && (value != null) && (value != DBNull.Value)) {\r
-                    _oleDbType = OleDbConvert.ValueTypeToOleDbType(value.GetType());\r
-                               }\r
-                base.Value = value;\r
-            }\r
-        }\r
-\r
-               protected internal sealed override bool IsSpecial {\r
-                       get {\r
-                               return (Direction == ParameterDirection.Output) && IsOracleRefCursor;\r
-                       }\r
-               }\r
-\r
-\r
-               internal bool IsOracleRefCursor\r
-               {\r
-                       get { return _isOracleRefCursor; }\r
-                       set { _isOracleRefCursor = value; }\r
-               }\r
-\r
-               #endregion // Properties\r
-\r
-               #region Methods\r
-\r
-               protected internal sealed override object ConvertValue(object value)\r
-               {\r
-                       // can not convert null or DbNull to other types\r
-                       if (value == null || value == DBNull.Value) {\r
-                               return value;\r
-                       }\r
-\r
-                       // FIXME : some other way to do this?\r
-                       if (OleDbType == OleDbType.Binary) {\r
-                               return value;\r
-                       }\r
-                       // .NET throws an exception to the user.\r
-                       object convertedValue  = value;\r
-\r
-                       // note : if we set user parameter jdbc type inside prepare interbal, the db type is not set\r
-                       if (value is IConvertible && (IsDbTypeSet || IsJdbcTypeSet)) {\r
-                               OleDbType oleDbType = (IsDbTypeSet) ? OleDbType : OleDbConvert.JdbcTypeToOleDbType((int)JdbcType);\r
-                               Type to = OleDbConvert.OleDbTypeToValueType(oleDbType);\r
-                               if (!(value is DateTime && to == DbTypes.TypeOfTimespan)) //anyway will go by jdbc type\r
-                                       convertedValue = Convert.ChangeType(value,to);\r
-                       }\r
-                       return convertedValue;\r
-               }\r
-\r
-               protected internal sealed override void SetParameterName(ResultSet res)\r
-               {\r
-                       ParameterName = res.getString("COLUMN_NAME");\r
-\r
-                       if (ParameterName.StartsWith("@")) {\r
-                               ParameterName = ParameterName.Remove(0,1);\r
-                       }\r
-               }\r
-\r
-               protected internal sealed override void SetParameterDbType(ResultSet res)\r
-               {\r
-                       int jdbcType = res.getInt("DATA_TYPE");                 \r
-                       // FIXME : is that correct?\r
-                       if (jdbcType == Types.OTHER) {\r
-                               string typeName = res.getString("TYPE_NAME");\r
-                               if (String.Compare ("BLOB", typeName, true, CultureInfo.InvariantCulture) == 0) {\r
-                                       jdbcType = Types.BLOB;\r
-                               }\r
-                               else if (String.Compare ("CLOB", typeName, true, CultureInfo.InvariantCulture) == 0) {\r
-                                       jdbcType = Types.CLOB;\r
-                               }\r
-                               else if (String.Compare ("FLOAT", typeName, true, CultureInfo.InvariantCulture) == 0) {\r
-                                       jdbcType = Types.FLOAT;\r
-                               }\r
-                               else if (String.Compare ("NVARCHAR2", typeName, true, CultureInfo.InvariantCulture) == 0) {\r
-                                       jdbcType = Types.VARCHAR;\r
-                               }\r
-                               else if (String.Compare ("NCHAR", typeName, true, CultureInfo.InvariantCulture) == 0) {\r
-                                       jdbcType = Types.VARCHAR;\r
-                               }\r
-                       }\r
-                       OleDbType = OleDbConvert.JdbcTypeToOleDbType(jdbcType);\r
-                       JdbcType = jdbcType;\r
-               }\r
-\r
-               protected internal sealed override void SetSpecialFeatures(ResultSet res)\r
-               {\r
-                       IsOracleRefCursor = (res.getString("TYPE_NAME") == "REF CURSOR");\r
-               }\r
-\r
-               protected internal sealed override int JdbcTypeFromProviderType()\r
-               {\r
-                       return OleDbConvert.OleDbTypeToJdbcType(OleDbType);\r
-               }\r
-\r
-               #endregion // Methods\r
-    \r
-    }\r
+               }
+#endif
+    
+        public new Object Value
+        {
+            get { return base.Value; }
+            set {
+                if (!IsDbTypeSet && (value != null) && (value != DBNull.Value)) {
+                    _oleDbType = OleDbConvert.ValueTypeToOleDbType(value.GetType());
+                               }
+                base.Value = value;
+            }
+        }
+
+               protected internal sealed override bool IsSpecial {
+                       get {
+                               return (Direction == ParameterDirection.Output) && IsOracleRefCursor;
+                       }
+               }
+
+
+               internal bool IsOracleRefCursor
+               {
+                       get { return _isOracleRefCursor; }
+                       set { _isOracleRefCursor = value; }
+               }
+
+               #endregion // Properties
+
+               #region Methods
+
+               protected internal sealed override object ConvertValue(object value)
+               {
+                       // can not convert null or DbNull to other types
+                       if (value == null || value == DBNull.Value) {
+                               return value;
+                       }
+
+                       // FIXME : some other way to do this?
+                       if (OleDbType == OleDbType.Binary) {
+                               return value;
+                       }
+                       // .NET throws an exception to the user.
+                       object convertedValue  = value;
+
+                       // note : if we set user parameter jdbc type inside prepare interbal, the db type is not set
+                       if (value is IConvertible && (IsDbTypeSet || IsJdbcTypeSet)) {
+                               OleDbType oleDbType = (IsDbTypeSet) ? OleDbType : OleDbConvert.JdbcTypeToOleDbType((int)JdbcType);
+                               Type to = OleDbConvert.OleDbTypeToValueType(oleDbType);
+                               if (!(value is DateTime && to == DbTypes.TypeOfTimespan)) //anyway will go by jdbc type
+                                       convertedValue = Convert.ChangeType(value,to);
+                       }
+                       return convertedValue;
+               }
+
+               protected internal sealed override void SetParameterName(ResultSet res)
+               {
+                       ParameterName = res.getString("COLUMN_NAME");
+
+                       if (ParameterName.StartsWith("@")) {
+                               ParameterName = ParameterName.Remove(0,1);
+                       }
+               }
+
+               protected internal sealed override void SetParameterDbType(ResultSet res)
+               {
+                       int jdbcType = res.getInt("DATA_TYPE");                 
+                       // FIXME : is that correct?
+                       if (jdbcType == Types.OTHER) {
+                               string typeName = res.getString("TYPE_NAME");
+                               if (String.Compare ("BLOB", typeName, true, CultureInfo.InvariantCulture) == 0) {
+                                       jdbcType = Types.BLOB;
+                               }
+                               else if (String.Compare ("CLOB", typeName, true, CultureInfo.InvariantCulture) == 0) {
+                                       jdbcType = Types.CLOB;
+                               }
+                               else if (String.Compare ("FLOAT", typeName, true, CultureInfo.InvariantCulture) == 0) {
+                                       jdbcType = Types.FLOAT;
+                               }
+                               else if (String.Compare ("NVARCHAR2", typeName, true, CultureInfo.InvariantCulture) == 0) {
+                                       jdbcType = Types.VARCHAR;
+                               }
+                               else if (String.Compare ("NCHAR", typeName, true, CultureInfo.InvariantCulture) == 0) {
+                                       jdbcType = Types.VARCHAR;
+                               }
+                       }
+                       OleDbType = OleDbConvert.JdbcTypeToOleDbType(jdbcType);
+                       JdbcType = jdbcType;
+               }
+
+#if NET_2_0
+               public void ResetOleDbType ()
+               {
+                       IsDbTypeSet = false;
+               }
+
+               public override void ResetDbType ()
+               {
+                       ResetOleDbType ();
+               }
+#endif
+
+               protected internal sealed override void SetSpecialFeatures(ResultSet res)
+               {
+                       IsOracleRefCursor = (res.getString("TYPE_NAME") == "REF CURSOR");
+               }
+
+               protected internal sealed override int JdbcTypeFromProviderType()
+               {
+                       return OleDbConvert.OleDbTypeToJdbcType(OleDbType);
+               }
+
+               #endregion // Methods
+    
+    }
 }
index 3e97e3d72df0c907060f08140dcfc527c7efb336..4c80ba7a2180240ca566d0f2cfc9a1e2ba922f65 100644 (file)
-//\r
-// System.Data.Common.OleDbParameterCollection\r
-//\r
-// Authors:\r
-//     Konstantin Triger <kostat@mainsoft.com>\r
-//     Boris Kirzner <borisk@mainsoft.com>\r
-//     \r
-// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)\r
-//\r
-\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-\r
-\r
-using System.Data.ProviderBase;\r
-\r
-namespace System.Data.OleDb\r
-{\r
-    public sealed class OleDbParameterCollection :  AbstractDbParameterCollection\r
-    {\r
-               #region Constructors\r
-\r
-        public OleDbParameterCollection(OleDbCommand parent): base(parent)\r
-        {\r
-        }\r
-\r
-               #endregion // Constructors\r
-\r
-               #region Properties\r
-        \r
-        public OleDbParameter this[int index]\r
-        {\r
-            get { return (OleDbParameter)base[index]; }\r
-            set { \r
-                               OnSchemaChanging();\r
-                               base[index] = value; \r
-                       }\r
-        }\r
-\r
-        public OleDbParameter this[string parameterName]\r
-        {\r
-            get { return (OleDbParameter)base[parameterName]; }\r
-            set { \r
-                               OnSchemaChanging();\r
-                               base[parameterName] = value; \r
-                       }\r
-        }\r
-\r
-               protected override Type ItemType { \r
-                       get { return typeof(OleDbParameter); }\r
-               }\r
-\r
-               #endregion // Properties\r
-\r
-               #region Methods\r
-\r
-        public OleDbParameter Add(OleDbParameter value)\r
-        {\r
-            base.Add(value);\r
-            return value;\r
-        }\r
-\r
-        public OleDbParameter Add(string parameterName, object value)\r
-        {\r
-            OleDbParameter param = new OleDbParameter(parameterName, value);\r
-            return Add(param);\r
-        }\r
-\r
-        public OleDbParameter Add(string parameterName, OleDbType sqlDbType)\r
-        {\r
-            OleDbParameter param = new OleDbParameter(parameterName, sqlDbType);\r
-            return Add(param);\r
-        }\r
-\r
-        public OleDbParameter Add(string parameterName, OleDbType sqlDbType, int size)\r
-        {\r
-            OleDbParameter param = new OleDbParameter(parameterName, sqlDbType, size);\r
-            return Add(param);\r
-        }\r
-\r
-        public OleDbParameter Add(string parameterName, OleDbType sqlDbType, int size, string sourceColumn)\r
-        {\r
-            OleDbParameter param = new OleDbParameter(parameterName, sqlDbType, size, sourceColumn);\r
-            return Add(param);\r
-               }\r
-\r
-#if NET_2_0\r
-               public OleDbParameter AddWithValue (string parameterName, object value)\r
-               {\r
-                       return Add (parameterName, value);\r
-               }\r
-\r
-               public bool Contains (OleDbParameter value)\r
-               {\r
-                       return base.Contains (value);\r
-               }\r
-\r
-               public void CopyTo (OleDbParameter [] array, int index)\r
-               {\r
-                       base.CopyTo (array, index);\r
-               }\r
-\r
-               public void Insert (int index, OleDbParameter value)\r
-               {\r
-                       base.Insert (index, value);\r
-               }\r
-\r
-               public void Remove (OleDbParameter value)\r
-               {\r
-                       base.Remove (value);\r
-               }\r
-#endif\r
-               #endregion // Methods        \r
-        \r
-    }\r
+//
+// System.Data.Common.OleDbParameterCollection
+//
+// Authors:
+//     Konstantin Triger <kostat@mainsoft.com>
+//     Boris Kirzner <borisk@mainsoft.com>
+//     
+// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System.Data.ProviderBase;
+
+namespace System.Data.OleDb
+{
+    public sealed class OleDbParameterCollection :  AbstractDbParameterCollection
+    {
+               #region Constructors
+
+        public OleDbParameterCollection(OleDbCommand parent): base(parent)
+        {
+        }
+
+               #endregion // Constructors
+
+               #region Properties
+        
+        public OleDbParameter this[int index]
+        {
+            get { return (OleDbParameter)base[index]; }
+            set { 
+                               OnSchemaChanging();
+                               base[index] = value; 
+                       }
+        }
+
+        public OleDbParameter this[string parameterName]
+        {
+            get { return (OleDbParameter)base[parameterName]; }
+            set { 
+                               OnSchemaChanging();
+                               base[parameterName] = value; 
+                       }
+        }
+
+               protected override Type ItemType { 
+                       get { return typeof(OleDbParameter); }
+               }
+
+               #endregion // Properties
+
+               #region Methods
+
+        public OleDbParameter Add(OleDbParameter value)
+        {
+            base.Add(value);
+            return value;
+        }
+
+        public OleDbParameter Add(string parameterName, object value)
+        {
+            OleDbParameter param = new OleDbParameter(parameterName, value);
+            return Add(param);
+        }
+
+        public OleDbParameter Add(string parameterName, OleDbType sqlDbType)
+        {
+            OleDbParameter param = new OleDbParameter(parameterName, sqlDbType);
+            return Add(param);
+        }
+
+        public OleDbParameter Add(string parameterName, OleDbType sqlDbType, int size)
+        {
+            OleDbParameter param = new OleDbParameter(parameterName, sqlDbType, size);
+            return Add(param);
+        }
+
+        public OleDbParameter Add(string parameterName, OleDbType sqlDbType, int size, string sourceColumn)
+        {
+            OleDbParameter param = new OleDbParameter(parameterName, sqlDbType, size, sourceColumn);
+            return Add(param);
+               }
+
+#if NET_2_0
+               public void AddRange (OleDbParameter [] values)
+               {
+                       base.AddRange (values);
+               }
+
+               public OleDbParameter AddWithValue (string parameterName, object value)
+               {
+                       return Add (parameterName, value);
+               }
+
+               public bool Contains (OleDbParameter value)
+               {
+                       return base.Contains (value);
+               }
+
+               public void CopyTo (OleDbParameter [] array, int index)
+               {
+                       base.CopyTo (array, index);
+               }
+
+               public void Insert (int index, OleDbParameter value)
+               {
+                       base.Insert (index, value);
+               }
+
+               public void Remove (OleDbParameter value)
+               {
+                       base.Remove (value);
+               }
+
+               public int IndexOf (OleDbParameter value)
+               {
+                       return base.IndexOf (value);
+               }
+
+#endif
+               #endregion // Methods        
+        
+    }
 }
\ No newline at end of file
index a26a72936ea0fc376b91e127c2f0d4ad3da2badc..173b524298af39381a77cbe323228ee008b9f4a9 100644 (file)
@@ -3646,12 +3646,12 @@ namespace MonoTests.System.Data
                        StringWriter writer1 = new StringWriter ();
                        table1.WriteXmlSchema (writer1, false);
                        string expected1 = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<xs:schema id=\"NewDataSet\" xmlns=\"\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n  <xs:element name=\"NewDataSet\" msdata:IsDataSet=\"true\" msdata:MainDataTable=\"Table1\" msdata:UseCurrentLocale=\"true\">\n    <xs:complexType>\n      <xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\n        <xs:element name=\"Table1\">\n          <xs:complexType>\n            <xs:sequence>\n              <xs:element name=\"ID\" type=\"xs:int\" />\n              <xs:element name=\"Name\" type=\"xs:string\" minOccurs=\"0\" />\n            </xs:sequence>\n          </xs:complexType>\n        </xs:element>\n      </xs:choice>\n    </xs:complexType>\n    <xs:unique name=\"Constraint1\" msdata:PrimaryKey=\"true\">\n      <xs:selector xpath=\".//Table1\" />\n      <xs:field xpath=\"ID\" />\n    </xs:unique>\n  </xs:element>\n</xs:schema>";
-                       Assert.AreEqual (expected1, writer1.ToString(), "#1");
+                       Assert.AreEqual (expected1, writer1.ToString().Replace("\r\n", "\n"), "#1");
 
                        StringWriter writer2 = new StringWriter ();
                        table1.WriteXmlSchema (writer2, true);
                        string expected2 = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\n<xs:schema id=\"NewDataSet\" xmlns=\"\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n  <xs:element name=\"NewDataSet\" msdata:IsDataSet=\"true\" msdata:MainDataTable=\"Table1\" msdata:UseCurrentLocale=\"true\">\n    <xs:complexType>\n      <xs:choice minOccurs=\"0\" maxOccurs=\"unbounded\">\n        <xs:element name=\"Table1\">\n          <xs:complexType>\n            <xs:sequence>\n              <xs:element name=\"ID\" type=\"xs:int\" />\n              <xs:element name=\"Name\" type=\"xs:string\" minOccurs=\"0\" />\n            </xs:sequence>\n          </xs:complexType>\n        </xs:element>\n        <xs:element name=\"Table2\">\n          <xs:complexType>\n            <xs:sequence>\n              <xs:element name=\"OrderID\" type=\"xs:int\" />\n              <xs:element name=\"CustomerID\" type=\"xs:int\" minOccurs=\"0\" />\n              <xs:element name=\"OrderDate\" type=\"xs:dateTime\" minOccurs=\"0\" />\n            </xs:sequence>\n          </xs:complexType>\n        </xs:element>\n      </xs:choice>\n    </xs:complexType>\n    <xs:unique name=\"Constraint1\" msdata:PrimaryKey=\"true\">\n      <xs:selector xpath=\".//Table1\" />\n      <xs:field xpath=\"ID\" />\n    </xs:unique>\n    <xs:unique name=\"Table2_Constraint1\" msdata:ConstraintName=\"Constraint1\" msdata:PrimaryKey=\"true\">\n      <xs:selector xpath=\".//Table2\" />\n      <xs:field xpath=\"OrderID\" />\n    </xs:unique>\n    <xs:keyref name=\"CustomerOrder\" refer=\"Constraint1\">\n      <xs:selector xpath=\".//Table2\" />\n      <xs:field xpath=\"CustomerID\" />\n    </xs:keyref>\n  </xs:element>\n</xs:schema>";
-                       Assert.AreEqual (expected2, writer2.ToString (), "#2");
+                       Assert.AreEqual (expected2, writer2.ToString ().Replace("\r\n", "\n"), "#2");
                }
 
                [Test]