Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSureshkumar T <suresh@mono-cvs.ximian.com>2005-03-10 15:48:43 +0300
committerSureshkumar T <suresh@mono-cvs.ximian.com>2005-03-10 15:48:43 +0300
commitb1ab44391f19795e8c405a2f363ed7cc294b784f (patch)
tree00c581a6374d2b613dad08df26309a28107fd14b /mcs/class/System.Data/System.Data.Odbc
parent9f0423eb2f85371bc2cde01aa638ddecd1ca4faa (diff)
In .:
2005-03-10 Sureshkumar T <tsureshkumar@novell.com> * System.Data.dll.sources: Added System.Data.Odbc/OdbcConnectionFactory.cs. System.Data.Odbc/OdbcFactory.cs. In System.Data.Odbc: 2005-03-10 Sureshkumar T <tsureshkumar@novell.com> Migrated core classes to derive from ProviderBase instead of implementing IDb* interfaces. Most part of these files have been branched with #if NET_2_0/ONLY_1_1. Make sure any changes works with both the profiles. * OdbcFactory.cs: Concrete Factory for DbProviderFactory. Factory to generate Connection,Command,etc. * OdbcConnectionFactory.cs: Concrete factory for DbConnectionFactory. * OdbcTransaction.cs: migration and overrides. * OdbcCommandBuilder.cs: migration and overrides. * OdbcDataReader.cs: --do--. no command behavior member as it will be maintained in base provider class. * OdbcParameterCollection.cs: --do--. Now, local ArrayList is not maintained here, instead it is in base class. Most of the methods which operated on this list are not needed in NET_2_0. * OdbcConnection.cs: Migration. connectionString is maintained in DbConnectionBase class. * OdbcParameter.cs: Migration. Many of the local members like value,sourceColumn are maintained in DbParameterBase. * OdbcCommand.cs: Migration. commandText,timeout and commandTimeOut are maintained in DbCommandBase class. svn path=/trunk/mcs/; revision=41643
Diffstat (limited to 'mcs/class/System.Data/System.Data.Odbc')
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/ChangeLog26
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs228
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcCommandBuilder.cs82
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs128
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs142
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs271
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs140
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs142
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcParameterCollection.cs149
-rw-r--r--mcs/class/System.Data/System.Data.Odbc/OdbcTransaction.cs48
10 files changed, 1188 insertions, 168 deletions
diff --git a/mcs/class/System.Data/System.Data.Odbc/ChangeLog b/mcs/class/System.Data/System.Data.Odbc/ChangeLog
index 8fc596d276a..77278eca971 100644
--- a/mcs/class/System.Data/System.Data.Odbc/ChangeLog
+++ b/mcs/class/System.Data/System.Data.Odbc/ChangeLog
@@ -1,5 +1,31 @@
2005-03-10 Sureshkumar T <tsureshkumar@novell.com>
+ Migrated core classes to derive from ProviderBase instead of
+ implementing IDb* interfaces. Most part of these files have been
+ branched with #if NET_2_0/ONLY_1_1. Make sure any changes works
+ with both the profiles.
+
+ * OdbcFactory.cs: Concrete Factory for DbProviderFactory. Factory
+ to generate Connection,Command,etc.
+
+ * OdbcConnectionFactory.cs: Concrete factory for DbConnectionFactory.
+
+ * OdbcTransaction.cs: migration and overrides.
+ * OdbcCommandBuilder.cs: migration and overrides.
+ * OdbcDataReader.cs: --do--. no command behavior member as it will
+ be maintained in base provider class.
+ * OdbcParameterCollection.cs: --do--. Now, local ArrayList is not
+ maintained here, instead it is in base class. Most of the methods
+ which operated on this list are not needed in NET_2_0.
+ * OdbcConnection.cs: Migration. connectionString is maintained in
+ DbConnectionBase class.
+ * OdbcParameter.cs: Migration. Many of the local members like
+ value,sourceColumn are maintained in DbParameterBase.
+ * OdbcCommand.cs: Migration. commandText,timeout and
+ commandTimeOut are maintained in DbCommandBase class.
+
+2005-03-10 Sureshkumar T <tsureshkumar@novell.com>
+
* OdbcType.cs: Added enums for SQL_TYPE & SQL_C_TYPE.
* libodbc.cs: Accept SQL_C_TYPE for driver
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs
index 64c4fcfe661..c98b6272dbc 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcCommand.cs
@@ -30,29 +30,41 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
+#if NET_2_0
+using System.Data.ProviderBase;
+#endif // NET_2_0
using System.Collections;
using System.Runtime.InteropServices;
namespace System.Data.Odbc
-{
- /// <summary>
+{
+ /// <summary>
/// Represents an SQL statement or stored procedure to execute against a data source.
/// </summary>
[DesignerAttribute ("Microsoft.VSDesigner.Data.VS.OdbcCommandDesigner, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.IDesigner")]
[ToolboxItemAttribute ("System.Drawing.Design.ToolboxItem, "+ Consts.AssemblySystem_Drawing)]
+#if NET_2_0
+ public sealed class OdbcCommand : DbCommandBase, ICloneable
+#else
public sealed class OdbcCommand : Component, ICloneable, IDbCommand
+#endif //NET_2_0
{
#region Fields
+#if ONLY_1_1
string commandText;
int timeout;
CommandType commandType;
+#endif // ONLY_1_1
+
OdbcConnection connection;
- OdbcParameterCollection parameters;
OdbcTransaction transaction;
+ OdbcParameterCollection _parameters;
+
bool designTimeVisible;
bool prepared=false;
OdbcDataReader dataReader;
@@ -64,12 +76,12 @@ namespace System.Data.Odbc
public OdbcCommand ()
{
- commandText = String.Empty;
- timeout = 30; // default timeout
- commandType = CommandType.Text;
- connection = null;
- parameters = new OdbcParameterCollection ();
- transaction = null;
+ this.CommandText = String.Empty;
+ this.CommandTimeout = 30; // default timeout
+ this.CommandType = CommandType.Text;
+ Connection = null;
+ _parameters = new OdbcParameterCollection ();
+ Transaction = null;
designTimeVisible = false;
dataReader = null;
}
@@ -89,7 +101,7 @@ namespace System.Data.Odbc
OdbcConnection connection,
OdbcTransaction transaction) : this (cmdText, connection)
{
- this.transaction = transaction;
+ this.Transaction = transaction;
}
#endregion // Constructors
@@ -102,6 +114,7 @@ namespace System.Data.Odbc
}
+#if ONLY_1_1
[OdbcCategory ("Data")]
[DefaultValue ("")]
[OdbcDescriptionAttribute ("Command text to execute")]
@@ -118,7 +131,25 @@ namespace System.Data.Odbc
}
}
-
+#else
+ [OdbcCategory ("Data")]
+ [DefaultValue ("")]
+ [OdbcDescriptionAttribute ("Command text to execute")]
+ [EditorAttribute ("Microsoft.VSDesigner.Data.Odbc.Design.OdbcCommandTextEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
+ [RefreshPropertiesAttribute (RefreshProperties.All)]
+ public override string CommandText
+ {
+ get {
+ return base.CommandText;
+ }
+ set {
+ prepared=false;
+ base.CommandText = value;
+ }
+ }
+#endif // ONLY_1_1
+
+#if ONLY_1_1
[OdbcDescriptionAttribute ("Time to wait for command to execute")]
[DefaultValue (30)]
public int CommandTimeout {
@@ -155,7 +186,18 @@ namespace System.Data.Odbc
connection = value;
}
}
-
+#endif // ONLY_1_1
+
+#if NET_2_0
+ public new OdbcConnection Connection
+ {
+ get { return DbConnection as OdbcConnection; }
+ set { DbConnection = value; }
+ }
+
+#endif // NET_2_0
+
+#if ONLY_1_1
[BrowsableAttribute (false)]
[DesignOnlyAttribute (true)]
[DefaultValue (true)]
@@ -168,19 +210,34 @@ namespace System.Data.Odbc
}
}
+#endif // ONLY_1_1
+
[OdbcCategory ("Data")]
[OdbcDescriptionAttribute ("The parameters collection")]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
- public OdbcParameterCollection Parameters {
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcParameterCollection Parameters {
get {
- return parameters;
+#if ONLY_1_1
+ return _parameters;
+#else
+ return base.Parameters as OdbcParameterCollection;
+#endif // ONLY_1_1
+
}
}
[BrowsableAttribute (false)]
[OdbcDescriptionAttribute ("The transaction used by the command")]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public OdbcTransaction Transaction {
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcTransaction Transaction {
get {
return transaction;
}
@@ -188,6 +245,8 @@ namespace System.Data.Odbc
transaction = value;
}
}
+
+#if ONLY_1_1
[OdbcCategory ("Behavior")]
[DefaultValue (UpdateRowSource.Both)]
@@ -210,14 +269,34 @@ namespace System.Data.Odbc
set {
Connection = (OdbcConnection) value;
}
- }
-
+ }
+#endif // ONLY_1_1
+#if NET_2_0
+ protected override DbConnection DbConnection
+ {
+ get { return connection; }
+ set {
+ connection = (OdbcConnection) value;
+ }
+ }
+
+#endif // NET_2_0
+
+#if ONLY_1_1
IDataParameterCollection IDbCommand.Parameters {
get {
return Parameters;
}
- }
-
+ }
+#else
+ protected override DbParameterCollection DbParameterCollection
+ {
+ get { return _parameters as DbParameterCollection;}
+ }
+
+#endif // NET_2_0
+
+#if ONLY_1_1
IDbTransaction IDbCommand.Transaction {
get {
return (IDbTransaction) Transaction;
@@ -232,13 +311,28 @@ namespace System.Data.Odbc
throw new ArgumentException ();
}
}
- }
+ }
+#else
+ protected override DbTransaction DbTransaction
+ {
+ get { return transaction; }
+ set {
+ transaction = (OdbcTransaction)value;
+ }
+ }
+#endif // ONLY_1_1
+
+
#endregion // Properties
#region Methods
- public void Cancel ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void Cancel ()
{
if (hstmt!=IntPtr.Zero)
{
@@ -250,15 +344,24 @@ namespace System.Data.Odbc
throw new InvalidOperationException();
}
- public OdbcParameter CreateParameter ()
- {
- return new OdbcParameter ();
- }
-
+#if ONLY_1_1
IDbDataParameter IDbCommand.CreateParameter ()
{
return CreateParameter ();
}
+
+ public OdbcParameter CreateParameter ()
+ {
+ return new OdbcParameter ();
+ }
+#else
+ protected override DbParameter CreateDbParameter ()
+ {
+ return CreateParameter ();
+ }
+
+#endif // ONLY_1_1
+
[MonoTODO]
protected override void Dispose (bool disposing)
@@ -269,7 +372,7 @@ namespace System.Data.Odbc
{
OdbcReturn ret;
- if ((parameters.Count>0) && !prepared)
+ if ((Parameters.Count>0) && !prepared)
Prepare();
if (prepared)
@@ -290,7 +393,11 @@ namespace System.Data.Odbc
}
}
- public int ExecuteNonQuery ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int ExecuteNonQuery ()
{
return ExecuteNonQuery (true);
}
@@ -298,9 +405,9 @@ namespace System.Data.Odbc
private int ExecuteNonQuery (bool freeHandle)
{
int records = 0;
- if (connection == null)
+ if (Connection == null)
throw new InvalidOperationException ();
- if (connection.State == ConnectionState.Closed)
+ if (Connection.State == ConnectionState.Closed)
throw new InvalidOperationException ();
// FIXME: a third check is mentioned in .NET docs
@@ -328,7 +435,11 @@ namespace System.Data.Odbc
return records;
}
- public void Prepare()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void Prepare()
{
OdbcReturn ret=libodbc.SQLAllocHandle(OdbcHandleType.Stmt, Connection.hDbc, ref hstmt);
if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
@@ -339,7 +450,7 @@ namespace System.Data.Odbc
throw new OdbcException(new OdbcError("SQLPrepare",OdbcHandleType.Stmt,hstmt));
int i=1;
- foreach (OdbcParameter p in parameters)
+ foreach (OdbcParameter p in Parameters)
{
p.Bind(hstmt, i);
i++;
@@ -348,28 +459,48 @@ namespace System.Data.Odbc
prepared=true;
}
- public OdbcDataReader ExecuteReader ()
+
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcDataReader ExecuteReader ()
{
return ExecuteReader (CommandBehavior.Default);
}
-
+
+#if ONLY_1_1
IDataReader IDbCommand.ExecuteReader ()
- {
+ {
return ExecuteReader ();
- }
-
- public OdbcDataReader ExecuteReader (CommandBehavior behavior)
- {
+ }
+#else
+ protected override DbDataReader ExecuteDbDataReader (CommandBehavior behavior)
+ {
+ return ExecuteReader (behavior);
+ }
+
+#endif // ONLY_1_1
+
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcDataReader ExecuteReader (CommandBehavior behavior)
+ {
ExecuteNonQuery(false);
dataReader=new OdbcDataReader(this,behavior);
return dataReader;
}
-
- IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior)
+
+#if ONLY_1_1
+ IDataReader IDbCommand.ExecuteReader (CommandBehavior behavior)
{
return ExecuteReader (behavior);
}
-
+#endif // ONLY_1_1
+
+#if ONLY_1_1
public object ExecuteScalar ()
{
object val = null;
@@ -384,17 +515,22 @@ namespace System.Data.Odbc
reader.Close();
}
return val;
- }
-
+ }
+#endif // ONLY_1_1
+
[MonoTODO]
object ICloneable.Clone ()
{
throw new NotImplementedException ();
}
- public void ResetCommandTimeout ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void ResetCommandTimeout ()
{
- timeout = 30;
+ CommandTimeout = 30;
}
#endregion
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcCommandBuilder.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcCommandBuilder.cs
index 4d27980f879..8945f943097 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcCommandBuilder.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcCommandBuilder.cs
@@ -39,7 +39,12 @@ namespace System.Data.Odbc
/// <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>
+
+#if ONLY_1_1
public sealed class OdbcCommandBuilder : Component
+#else // NET_2_0 and higher
+ public sealed class OdbcCommandBuilder : DbCommandBuilder
+#endif // ONLY_1_1
{
#region Fields
@@ -70,7 +75,11 @@ namespace System.Data.Odbc
[OdbcDescriptionAttribute ("The DataAdapter for which to automatically generate OdbcCommands")]
[DefaultValue (null)]
- public OdbcDataAdapter DataAdapter {
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcDataAdapter DataAdapter {
get {
return adapter;
}
@@ -82,7 +91,11 @@ namespace System.Data.Odbc
[BrowsableAttribute (false)]
[OdbcDescriptionAttribute ("The prefix string wrapped around sql objects")]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public string QuotePrefix {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ string QuotePrefix {
get {
return quotePrefix;
}
@@ -94,7 +107,11 @@ namespace System.Data.Odbc
[BrowsableAttribute (false)]
[OdbcDescriptionAttribute ("The suffix string wrapped around sql objects")]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public string QuoteSuffix {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ string QuoteSuffix {
get {
return quoteSuffix;
}
@@ -119,28 +136,79 @@ namespace System.Data.Odbc
}
[MonoTODO]
- public OdbcCommand GetDeleteCommand ()
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcCommand GetDeleteCommand ()
{
throw new NotImplementedException ();
}
[MonoTODO]
- public OdbcCommand GetInsertCommand ()
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcCommand GetInsertCommand ()
{
throw new NotImplementedException ();
}
[MonoTODO]
- public OdbcCommand GetUpdateCommand ()
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcCommand GetUpdateCommand ()
{
throw new NotImplementedException ();
}
[MonoTODO]
- public void RefreshSchema ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void RefreshSchema ()
{
throw new NotImplementedException ();
}
+
+#if NET_2_0
+ [MonoTODO]
+ protected override void ApplyParameterInfo (IDbDataParameter dbParameter, DataRow row)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override string GetParameterName (int position)
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ [MonoTODO]
+ protected override string GetParameterPlaceholder (int position)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override DbProviderFactory ProviderFactory
+ {
+ get {throw new NotImplementedException ();}
+ }
+
+ [MonoTODO]
+ protected override void SetRowUpdatingHandler (DbDataAdapter adapter)
+ {
+ throw new NotImplementedException ();
+ }
+
+#endif // NET_2_0
+
#endregion // Methods
}
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs
index 718f67a1dcd..35163a556fd 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs
@@ -33,16 +33,26 @@
using System.ComponentModel;
using System.Data;
using System.Data.Common;
+#if NET_2_0
+using System.Data.ProviderBase;
+#endif // NET_2_0
using System.EnterpriseServices;
namespace System.Data.Odbc
{
[DefaultEvent("InfoMessage")]
+#if NET_2_0
+ public sealed class OdbcConnection : DbConnectionBase, ICloneable
+#else
public sealed class OdbcConnection : Component, ICloneable, IDbConnection
+#endif //NET_2_0
{
#region Fields
+#if ONLY_1_1
string connectionString;
+#endif //ONLY_1_1
+
int connectionTimeout;
internal OdbcTransaction transaction;
IntPtr henv=IntPtr.Zero, hdbc=IntPtr.Zero;
@@ -52,17 +62,31 @@ namespace System.Data.Odbc
#region Constructors
- public OdbcConnection ()
+ public OdbcConnection () : this (String.Empty)
{
- connectionTimeout = 15;
- connectionString = null;
}
- public OdbcConnection (string connectionString) : this ()
+ public OdbcConnection (string connectionString)
{
- ConnectionString = connectionString;
+ Init (connectionString);
}
+ public void Init (string connectionString)
+ {
+ connectionTimeout = 15;
+ ConnectionString = connectionString;
+ }
+
+#if NET_2_0
+ internal OdbcConnection (OdbcConnectionFactory factory)
+ : base ( (DbConnectionFactory) factory)
+ {
+ Init (String.Empty);
+ }
+
+#endif //NET_2_0
+
+
#endregion // Constructors
#region Properties
@@ -71,7 +95,8 @@ namespace System.Data.Odbc
{
get { return hdbc; }
}
-
+
+#if ONLY_1_1
[OdbcCategoryAttribute ("DataCategory_Data")]
[DefaultValue ("")]
[OdbcDescriptionAttribute ("Information used to connect to a Data Source")]
@@ -86,10 +111,15 @@ namespace System.Data.Odbc
connectionString = value;
}
}
+#endif // ONLY_1_1
[OdbcDescriptionAttribute ("Current connection timeout value, not settable in the ConnectionString")]
[DefaultValue (15)]
- public int ConnectionTimeout {
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ int ConnectionTimeout {
get {
return connectionTimeout;
}
@@ -103,7 +133,11 @@ namespace System.Data.Odbc
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
[OdbcDescriptionAttribute ("Current data source Catlog value, 'Database=X' in the ConnectionString")]
- public string Database {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ string Database {
get {
return GetInfo (OdbcInfo.DatabaseName);
}
@@ -112,7 +146,11 @@ namespace System.Data.Odbc
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
[OdbcDescriptionAttribute ("The ConnectionState indicating whether the connection is open or closed")]
[BrowsableAttribute (false)]
- public ConnectionState State
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ ConnectionState State
{
get {
if (hdbc!=IntPtr.Zero) {
@@ -126,7 +164,11 @@ namespace System.Data.Odbc
[MonoTODO]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
[OdbcDescriptionAttribute ("Current data source, 'Server=X' in the ConnectionString")]
- public string DataSource {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ string DataSource {
get {
return GetInfo (OdbcInfo.DataSourceName);
}
@@ -145,7 +187,11 @@ namespace System.Data.Odbc
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
[OdbcDescriptionAttribute ("Version of the product accessed by the ODBC Driver")]
[BrowsableAttribute (false)]
- public string ServerVersion {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ string ServerVersion {
get {
return GetInfo (OdbcInfo.DbmsVersion);
}
@@ -156,17 +202,27 @@ namespace System.Data.Odbc
#region Methods
- public OdbcTransaction BeginTransaction ()
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcTransaction BeginTransaction ()
{
return BeginTransaction(IsolationLevel.Unspecified);
- }
-
+ }
+
+#if ONLY_1_1
IDbTransaction IDbConnection.BeginTransaction ()
{
return (IDbTransaction) BeginTransaction();
}
+#endif // ONLY_1_1
- public OdbcTransaction BeginTransaction (IsolationLevel level)
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcTransaction BeginTransaction (IsolationLevel level)
{
if (transaction==null)
{
@@ -177,12 +233,18 @@ namespace System.Data.Odbc
throw new InvalidOperationException();
}
+#if ONLY_1_1
IDbTransaction IDbConnection.BeginTransaction (IsolationLevel level)
{
return (IDbTransaction) BeginTransaction(level);
}
+#endif // ONLY_1_1
- public void Close ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void Close ()
{
OdbcReturn ret = OdbcReturn.Error;
if (State == ConnectionState.Open) {
@@ -210,13 +272,21 @@ namespace System.Data.Odbc
}
}
- public OdbcCommand CreateCommand ()
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ OdbcCommand CreateCommand ()
{
return new OdbcCommand("", this, transaction);
}
[MonoTODO]
- public void ChangeDatabase(string Database)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void ChangeDatabase(string Database)
{
throw new NotImplementedException ();
}
@@ -244,12 +314,18 @@ namespace System.Data.Odbc
throw new NotImplementedException();
}
+#if ONLY_1_1
IDbCommand IDbConnection.CreateCommand ()
{
return (IDbCommand) CreateCommand ();
}
+#endif //ONLY_1_1
- public void Open ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void Open ()
{
if (State == ConnectionState.Open)
throw new InvalidOperationException ();
@@ -271,10 +347,10 @@ namespace System.Data.Odbc
throw new OdbcException (new OdbcError ("SQLAllocHandle",OdbcHandleType.Env,henv));
// DSN connection
- if (connectionString.ToLower().IndexOf("dsn=")>=0)
+ if (ConnectionString.ToLower().IndexOf("dsn=")>=0)
{
string _uid="", _pwd="", _dsn="";
- string[] items=connectionString.Split(new char[1]{';'});
+ string[] items=ConnectionString.Split(new char[1]{';'});
foreach (string item in items)
{
string[] parts=item.Split(new char[1] {'='});
@@ -300,7 +376,7 @@ namespace System.Data.Odbc
// DSN-less Connection
string OutConnectionString=new String(' ',1024);
short OutLen=0;
- ret=libodbc.SQLDriverConnect(hdbc, IntPtr.Zero, connectionString, -3,
+ ret=libodbc.SQLDriverConnect(hdbc, IntPtr.Zero, ConnectionString, -3,
OutConnectionString, (short) OutConnectionString.Length, ref OutLen, 0);
if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
throw new OdbcException(new OdbcError("SQLDriverConnect",OdbcHandleType.Dbc,hdbc));
@@ -315,7 +391,11 @@ namespace System.Data.Odbc
}
[MonoTODO]
- public void EnlistDistributedTransaction ( ITransaction transaction) {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void EnlistDistributedTransaction ( ITransaction transaction) {
throw new NotImplementedException ();
}
@@ -343,9 +423,11 @@ namespace System.Data.Odbc
#region Events and Delegates
+#if ONLY_1_1
[OdbcDescription ("DbConnection_StateChange")]
[OdbcCategory ("DataCategory_StateChange")]
public event StateChangeEventHandler StateChange;
+#endif // ONLY_1_1
[OdbcDescription ("DbConnection_InfoMessage")]
[OdbcCategory ("DataCategory_InfoMessage")]
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs
new file mode 100644
index 00000000000..7819b14fc2b
--- /dev/null
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcConnectionFactory.cs
@@ -0,0 +1,142 @@
+//
+// System.Data.Odbc.OdbcConnectionFactory
+//
+// Author:
+// Sureshkumar T <tsureshkumar@novell.com>
+//
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.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.
+//
+
+#if NET_2_0
+
+using System.Data;
+using System.Data.Common;
+using System.Data.ProviderBase;
+
+namespace System.Data.Odbc {
+ internal class OdbcConnectionFactory : DbConnectionFactory
+ {
+ #region Fields
+ internal static OdbcConnectionFactory Instance; // singleton
+ private static DbProviderFactory _providerFactory;
+ #endregion // Fields
+
+ #region Constructors
+
+ private OdbcConnectionFactory (DbProviderFactory pvdrfactory)
+ {
+ _providerFactory = pvdrfactory;
+ }
+
+ #endregion // Constructors
+
+ #region Properties
+
+ public override DbProviderFactory ProviderFactory { get { return _providerFactory; }}
+
+ #endregion // Properties
+
+ #region Methods
+
+ // create singleton connection factory.
+ internal static OdbcConnectionFactory GetSingleton (OdbcFactory pvdrFactory)
+ {
+ lock (typeof (OdbcConnectionFactory))
+ {
+ if (Instance == null)
+ Instance = new OdbcConnectionFactory (pvdrFactory);
+ return Instance;
+ }
+ }
+
+ [MonoTODO]
+ protected override IAsyncResult BeginCreateConnection (DbConnectionBase owningObject, DbConnectionString connectionOptions, DbConnectionInternal connection, AsyncCallback callback, object asyncStateObject)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public new void ClearAllPools ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public new void ClearPool (DbConnectionBase connection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override DbConnectionInternal CreateConnection (DbConnectionString options, DbConnectionBase owningObject)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override DbConnectionString CreateConnectionOptions (string connectionString)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override DbConnectionPoolOptions CreateConnectionPoolOptions (DbConnectionString options)
+ {
+ throw new NotImplementedException ();
+ }
+
+
+ [MonoTODO]
+ protected override DbMetaDataFactory CreateMetaDataFactory (DbConnectionInternal internalConnection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override DbConnectionInternal EndCreateConnection (IAsyncResult asyncResult)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected internal new DbMetaDataFactory GetMetaDataFactory (DbConnectionString connectionOptions, DbConnectionInternal internalConnection)
+ {
+ throw new NotImplementedException ();
+ }
+
+ internal new DbConnectionString CreateConnectionOptionsInternal (string connectionString)
+ {
+ return CreateConnectionOptions (connectionString);
+ }
+
+ [MonoTODO]
+ public new void SetConnectionPoolOptions (string connectionString, DbConnectionPoolOptions poolOptions)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion // Methods
+ }
+}
+
+#endif
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs
index 2597dee1b51..1a9f27d43e0 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs
@@ -37,11 +37,18 @@ using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
+#if NET_2_0
+using System.Data.ProviderBase;
+#endif // NET_2_0
using System.Text;
namespace System.Data.Odbc
{
+#if NET_2_0
+ public sealed class OdbcDataReader : DbDataReaderBase
+#else
public sealed class OdbcDataReader : MarshalByRefObject, IDataReader, IDisposable, IDataRecord, IEnumerable
+#endif
{
#region Fields
@@ -50,16 +57,23 @@ namespace System.Data.Odbc
private int currentRow;
private OdbcColumn[] cols;
private IntPtr hstmt;
+#if ONLY_1_1
private CommandBehavior behavior;
+#endif // ONLY_1_1
#endregion
#region Constructors
- internal OdbcDataReader (OdbcCommand command, CommandBehavior behavior)
+ internal OdbcDataReader (OdbcCommand command, CommandBehavior behavior)
+#if NET_2_0
+ : base (behavior)
+#endif // NET_2_0
{
this.command = command;
- this.behavior=behavior;
+#if ONLY_1_1
+ this.CommandBehavior=behavior;
+#endif // ONLY_1_1
open = true;
currentRow = -1;
hstmt=command.hStmt;
@@ -74,25 +88,63 @@ namespace System.Data.Odbc
#region Properties
- public int Depth {
+#if ONLY_1_1
+ private CommandBehavior CommandBehavior
+ {
+ get { return behavior; }
+ set { value = behavior; }
+ }
+#endif // ONLY_1_1
+
+#if NET_2_0
+ [MonoTODO]
+ public override int VisibleFieldCount
+ {
+ get { throw new NotImplementedException (); }
+ }
+
+ [MonoTODO]
+ protected override bool IsValidRow
+ {
+ get { throw new NotImplementedException (); }
+ }
+
+#endif // NET_2_0
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int Depth {
get {
return 0; // no nested selects supported
}
}
- public int FieldCount {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int FieldCount {
get {
return cols.Length;
}
}
- public bool IsClosed {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ bool IsClosed {
get {
return !open;
}
}
- public object this[string name] {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ object this[string name] {
get {
int pos;
@@ -108,20 +160,33 @@ namespace System.Data.Odbc
}
}
- public object this[int index] {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ object this[int index] {
get {
return (object) GetValue (index);
}
}
- public int RecordsAffected {
+ [MonoTODO]
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int RecordsAffected {
get {
return -1;
}
}
[MonoTODO]
- public bool HasRows {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ bool HasRows {
get { throw new NotImplementedException(); }
}
@@ -169,7 +234,11 @@ namespace System.Data.Odbc
return cols[ordinal];
}
- public void Close ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void Close ()
{
// FIXME : have to implement output parameter binding
OdbcReturn ret = libodbc.SQLFreeStmt (hstmt, libodbc.SQLFreeStmtOptions.Close);
@@ -183,7 +252,7 @@ namespace System.Data.Odbc
if ((ret!=OdbcReturn.Success) && (ret!=OdbcReturn.SuccessWithInfo))
throw new OdbcException(new OdbcError("SQLFreeHandle",OdbcHandleType.Stmt,hstmt));
- if ((behavior & CommandBehavior.CloseConnection)==CommandBehavior.CloseConnection)
+ if ((this.CommandBehavior & CommandBehavior.CloseConnection)==CommandBehavior.CloseConnection)
this.command.Connection.Close();
}
@@ -193,17 +262,29 @@ namespace System.Data.Odbc
Close ();
}
- public bool GetBoolean (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ bool GetBoolean (int ordinal)
{
return (bool) GetValue(ordinal);
}
- public byte GetByte (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ byte GetByte (int ordinal)
{
return (byte) Convert.ToByte(GetValue(ordinal));
}
- public long GetBytes (int ordinal, long dataIndex, byte[] buffer, int bufferIndex, int length)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ long GetBytes (int ordinal, long dataIndex, byte[] buffer, int bufferIndex, int length)
{
OdbcReturn ret = OdbcReturn.Error;
bool copyBuffer = false;
@@ -257,25 +338,41 @@ namespace System.Data.Odbc
}
[MonoTODO]
- public char GetChar (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ char GetChar (int ordinal)
{
throw new NotImplementedException ();
}
[MonoTODO]
- public long GetChars (int ordinal, long dataIndex, char[] buffer, int bufferIndex, int length)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ long GetChars (int ordinal, long dataIndex, char[] buffer, int bufferIndex, int length)
{
throw new NotImplementedException ();
}
[MonoTODO]
[EditorBrowsableAttribute (EditorBrowsableState.Never)]
- public IDataReader GetData (int ordinal)
+ public
+#if NET_2_0
+ new
+#endif // NET_2_0
+ IDataReader GetData (int ordinal)
{
throw new NotImplementedException ();
}
- public string GetDataTypeName (int index)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ string GetDataTypeName (int index)
{
return GetColumn(index).OdbcType.ToString();
}
@@ -284,59 +381,103 @@ namespace System.Data.Odbc
return GetDateTime(ordinal);
}
- public DateTime GetDateTime (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ DateTime GetDateTime (int ordinal)
{
return (DateTime) GetValue(ordinal);
}
[MonoTODO]
- public decimal GetDecimal (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ decimal GetDecimal (int ordinal)
{
throw new NotImplementedException ();
}
- public double GetDouble (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ double GetDouble (int ordinal)
{
return (double) GetValue(ordinal);
}
- public Type GetFieldType (int index)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ Type GetFieldType (int index)
{
return GetColumn(index).DataType;
}
- public float GetFloat (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ float GetFloat (int ordinal)
{
return (float) GetValue(ordinal);
}
[MonoTODO]
- public Guid GetGuid (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ Guid GetGuid (int ordinal)
{
throw new NotImplementedException ();
}
- public short GetInt16 (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ short GetInt16 (int ordinal)
{
return (short) GetValue(ordinal);
}
- public int GetInt32 (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int GetInt32 (int ordinal)
{
return (int) GetValue(ordinal);
}
- public long GetInt64 (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ long GetInt64 (int ordinal)
{
return (long) GetValue(ordinal);
}
- public string GetName (int index)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ string GetName (int index)
{
return GetColumn(index).ColumnName;
}
- public int GetOrdinal (string name)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int GetOrdinal (string name)
{
int i=ColIndex(name);
@@ -347,7 +488,11 @@ namespace System.Data.Odbc
}
[MonoTODO]
- public DataTable GetSchemaTable()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ DataTable GetSchemaTable()
{
DataTable dataTableSchema = null;
@@ -434,7 +579,11 @@ namespace System.Data.Odbc
return dataTableSchema;
}
- public string GetString (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ string GetString (int ordinal)
{
return (string) GetValue(ordinal);
}
@@ -445,7 +594,11 @@ namespace System.Data.Odbc
throw new NotImplementedException ();
}
- public object GetValue (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ object GetValue (int ordinal)
{
if (currentRow == -1)
throw new IndexOutOfRangeException ();
@@ -562,7 +715,11 @@ namespace System.Data.Odbc
return col.Value;
}
- public int GetValues (object[] values)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int GetValues (object[] values)
{
int numValues = 0;
@@ -587,7 +744,9 @@ namespace System.Data.Odbc
return numValues;
}
- [MonoTODO]
+#if ONLY_1_1
+
+ [MonoTODO]
IDataReader IDataRecord.GetData (int ordinal)
{
throw new NotImplementedException ();
@@ -598,13 +757,17 @@ namespace System.Data.Odbc
{
}
- [MonoTODO]
- IEnumerator IEnumerable.GetEnumerator ()
+ IEnumerator IEnumerable.GetEnumerator ()
{
return new DbEnumerator (this);
}
+#endif // ONLY_1_1
- public bool IsDBNull (int ordinal)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ bool IsDBNull (int ordinal)
{
return (GetValue(ordinal) is DBNull);
}
@@ -612,7 +775,11 @@ namespace System.Data.Odbc
/// <remarks>
/// Move to the next result set.
/// </remarks>
- public bool NextResult ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ bool NextResult ()
{
OdbcReturn ret = OdbcReturn.Success;
ret = libodbc.SQLMoreResults (hstmt);
@@ -645,11 +812,37 @@ namespace System.Data.Odbc
return (ret == OdbcReturn.Success);
}
- public bool Read ()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ bool Read ()
{
return NextRow ();
}
+#if NET_2_0
+ [MonoTODO]
+ public override object GetProviderSpecificValue (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override int GetProviderSpecificValues (object[] values)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override Type GetFieldProviderSpecificType (int i)
+ {
+ throw new NotImplementedException ();
+ }
+
+#endif // NET_2_0
+
+
#endregion
}
}
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs
new file mode 100644
index 00000000000..90b95c3e6aa
--- /dev/null
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs
@@ -0,0 +1,140 @@
+//
+// System.Data.Odbc.OdbcFactory
+//
+// Author:
+// Sureshkumar T <tsureshkumar@novell.com>
+//
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.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.
+//
+
+#if NET_2_0
+
+#region Using Directives
+using System;
+using System.Data;
+using System.Data.Common;
+using System.Data.ProviderBase;
+#endregion // Using Directives
+
+namespace System.Data.Odbc
+{
+
+ public sealed class OdbcFactory : DbProviderFactory
+ {
+ #region Fields
+ public static readonly OdbcFactory Instance;
+ #endregion //Fields
+
+ #region Constructors
+ /// <remarks>
+ /// public static variable Instance should hold the the singleton instance
+ /// based on the knowledge that custom factories without this instance variable
+ /// ms.net throws exception
+ /// <pre>
+ /// System.InvalidOperationException: The requested .Net Framework Data
+ /// Provider's implementation does not have an Instance field
+ /// of a System.Data.Common.DbProviderFactory derived type.
+ /// at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
+ /// at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
+ /// </pre>
+ /// </remarks>
+ static OdbcFactory()
+ {
+ lock (typeof (OdbcFactory))
+ {
+ if (Instance == null)
+ Instance = new OdbcFactory ();
+ }
+
+ }
+
+ private OdbcFactory()
+ {
+
+ }
+
+ #endregion //Constructors
+
+ #region Properties
+ public override DbProviderSupportedClasses SupportedClasses {
+ get {
+ return (DbProviderSupportedClasses) (
+ DbProviderSupportedClasses.DbConnection |
+ DbProviderSupportedClasses.DbCommand |
+ DbProviderSupportedClasses.DbParameter |
+ //DbProviderSupportedClasses.DbConnectionStringBuilder |
+ DbProviderSupportedClasses.DbCommandBuilder |
+ DbProviderSupportedClasses.DbDataAdapter //|
+ //DbProviderSupportedClasses.DbDataSourceEnumerator |
+ //DbProviderSupportedClasses.CodeAccessPermission
+ );
+ }
+ }
+
+ #endregion //Properties
+
+ #region Methods
+ public override DbConnection CreateConnection()
+ {
+ OdbcConnectionFactory connFactory = OdbcConnectionFactory.GetSingleton (this);
+ return new OdbcConnection (connFactory);
+ }
+
+ public override DbCommand CreateCommand()
+ {
+ return new OdbcCommand () as DbCommand;
+ }
+
+ public override DbCommandBuilder CreateCommandBuilder()
+ {
+ return new OdbcCommandBuilder () as DbCommandBuilder;
+ }
+
+
+// public override DbConnectionStringBuilder CreateConnectionStringBuilder()
+// {
+// throw new NotImplementedException ();
+// }
+
+ public override DbDataAdapter CreateDataAdapter()
+ {
+ return new OdbcDataAdapter () as DbDataAdapter;
+ }
+
+ public override DbParameter CreateParameter()
+ {
+ return new OdbcParameter () as DbParameter;
+ }
+
+// public override CodeAccessPermission CreatePermission(PermissionState state)
+// {
+// throw new NotImplementedException ();
+// }
+
+ #endregion //Methods
+
+ }
+
+
+}
+#endif // NET_2_0
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
index 037b6340dcd..0024003d666 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcParameter.cs
@@ -3,6 +3,7 @@
//
// Authors:
// Brian Ritchie (brianlritchie@hotmail.com)
+// Sureshkumar T <tsureshkumar@novell.com> 2004.
//
// Copyright (C) Brian Ritchie, 2002
//
@@ -33,24 +34,33 @@
using System;
using System.Data;
using System.Data.Common;
+#if NET_2_0
+using System.Data.ProviderBase;
+#endif // NET_2_0
using System.ComponentModel;
namespace System.Data.Odbc
{
- [TypeConverterAttribute (typeof (OdbcParameterConverter))]
+ [TypeConverterAttribute (typeof (OdbcParameterConverter))]
+#if NET_2_0
+ public sealed class OdbcParameter : DbParameterBase, ICloneable
+#else
public sealed class OdbcParameter : MarshalByRefObject, IDbDataParameter, IDataParameter, ICloneable
+#endif // NET_2_0
{
#region Fields
+#if ONLY_1_1
string name;
- object ParamValue;
- int size;
+ ParameterDirection direction;
bool isNullable;
+ int size;
byte precision;
byte scale;
+ object paramValue;
DataRowVersion sourceVersion;
string sourceColumn;
- ParameterDirection direction;
+#endif // ONLY_1_1
OdbcType odbcType = OdbcType.NVarChar;
DbType dbType = DbType.String;
OdbcParameterCollection container = null;
@@ -67,28 +77,28 @@ namespace System.Data.Odbc
public OdbcParameter ()
{
- name = String.Empty;
- ParamValue = null;
- size = 0;
- isNullable = true;
- precision = 0;
- scale = 0;
- sourceColumn = String.Empty;
+ ParameterName = String.Empty;
+ Value = null;
+ Size = 0;
+ IsNullable = true;
+ Precision = 0;
+ Scale = 0;
+ SourceColumn = String.Empty;
}
public OdbcParameter (string name, object value)
: this ()
{
- this.name = name;
- this.ParamValue = value;
+ this.ParameterName = name;
+ this.Value = value;
if (value != null && !value.GetType ().IsValueType) {
Type type = value.GetType ();
if (type.IsArray)
- size = type.GetElementType () == typeof (byte) ?
+ Size = type.GetElementType () == typeof (byte) ?
((Array) value).Length : 0;
else
- size = value.ToString ().Length;
+ Size = value.ToString ().Length;
}
@@ -97,32 +107,32 @@ namespace System.Data.Odbc
public OdbcParameter (string name, OdbcType dataType)
: this ()
{
- this.name = name;
+ this.ParameterName = name;
OdbcType = dataType;
}
public OdbcParameter (string name, OdbcType dataType, int size)
: this (name, dataType)
{
- this.size = size;
+ this.Size = size;
}
public OdbcParameter (string name, OdbcType dataType, int size, string srcColumn)
: this (name, dataType, size)
{
- this.sourceColumn = srcColumn;
+ this.SourceColumn = srcColumn;
}
[EditorBrowsable (EditorBrowsableState.Advanced)]
public OdbcParameter(string name, OdbcType dataType, int size, ParameterDirection direction, bool isNullable, byte precision, byte scale, string srcColumn, DataRowVersion srcVersion, object value)
: this (name, dataType, size, srcColumn)
{
- this.direction = direction;
- this.isNullable = isNullable;
- this.precision = precision;
- this.scale = scale;
- this.sourceVersion = srcVersion;
- this.ParamValue = value;
+ this.Direction = direction;
+ this.IsNullable = isNullable;
+ this.Precision = precision;
+ this.Scale = scale;
+ this.SourceVersion = srcVersion;
+ this.Value = value;
}
#endregion
@@ -141,13 +151,18 @@ namespace System.Data.Odbc
[RefreshPropertiesAttribute (RefreshProperties.All)]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
[OdbcCategory ("Data")]
- public DbType DbType {
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ DbType DbType {
get { return dbType; }
set {
dbType = value;
}
}
+#if ONLY_1_1
[OdbcCategory ("Data")]
[OdbcDescriptionAttribute ("Input, output, or bidirectional parameter")]
[DefaultValue (ParameterDirection.Input)]
@@ -165,6 +180,8 @@ namespace System.Data.Odbc
get { return isNullable; }
set { isNullable = value; }
}
+#endif // ONLY_1_1
+
[DefaultValue (OdbcType.NChar)]
[OdbcDescriptionAttribute ("The parameter native type")]
@@ -177,6 +194,7 @@ namespace System.Data.Odbc
}
}
+#if ONLY_1_1
[OdbcDescription ("DataParameter_ParameterName")]
[DefaultValue ("")]
public string ParameterName {
@@ -230,14 +248,33 @@ namespace System.Data.Odbc
[DefaultValue (null)]
public object Value {
get {
- return ParamValue;
+ return paramValue;
+ }
+ set {
+ paramValue = value;
+ bufferIsSet = false;
+ }
+ }
+#endif // ONLY_1_1
+
+#if NET_2_0
+ [TypeConverter (typeof(StringConverter))]
+ [OdbcDescription ("DataParameter_Value")]
+ [OdbcCategory ("DataCategory_Data")]
+ [DefaultValue (null)]
+ public override object Value {
+ get {
+ return base.Value;
}
set {
- this.ParamValue = value;
+ base.Value = value;
bufferIsSet = false;
}
}
+#endif // NET_2_0
+
+
#endregion // Properties
#region Methods
@@ -249,7 +286,7 @@ namespace System.Data.Odbc
setBuffer();
// Convert System.Data.ParameterDirection into odbc enum
- OdbcInputOutputDirection paramdir = libodbc.ConvertParameterDirection(this.direction);
+ OdbcInputOutputDirection paramdir = libodbc.ConvertParameterDirection(this.Direction);
SQL_C_TYPE ctype = OdbcTypeConverter.ConvertToSqlCType (odbcType);
SQL_TYPE sqltype = OdbcTypeConverter.ConvertToSqlType (odbcType);
@@ -257,11 +294,11 @@ namespace System.Data.Odbc
// Bind parameter based on type
if (odbcType == OdbcType.Int)
ret = libodbc.SQLBindParameter(hstmt, (ushort)ParamNum, (short)paramdir,
- ctype, sqltype, Convert.ToUInt32(size),
+ ctype, sqltype, Convert.ToUInt32(Size),
0, ref intbuf, 0, 0);
else
ret = libodbc.SQLBindParameter(hstmt, (ushort)ParamNum, (short)paramdir,
- ctype, sqltype, Convert.ToUInt32(size),
+ ctype, sqltype, Convert.ToUInt32(Size),
0, buffer, 0, 0);
@@ -273,17 +310,17 @@ namespace System.Data.Odbc
private void setBuffer() {
// Load buffer with new value
if (odbcType == OdbcType.Int)
- intbuf = ParamValue == null ? new int () : (int) ParamValue;
+ intbuf = Value == null ? new int () : (int) Value;
else {
- string paramValueString = ParamValue.ToString();
+ string paramValueString = Value.ToString();
// Treat everything else as a string
// Init string buffer
- if (ParamValue is String)
+ if (Value is String)
paramValueString = "\'"+paramValueString+"\'";
- int minSize = size;
- minSize = size > 20 ? size : 20;
- if (ParamValue is String)
+ int minSize = Size;
+ minSize = Size > 20 ? Size : 20;
+ if (Value is String)
minSize += 2; // for enclosing apos
if (buffer == null || buffer.Length < minSize)
buffer = new byte[minSize];
@@ -307,6 +344,39 @@ namespace System.Data.Odbc
{
return ParameterName;
}
+
+#if NET_2_0
+ [MonoTODO]
+ public override void PropertyChanging ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override byte ValuePrecision (object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override byte ValueScale (object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ protected override int ValueSize (object value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override void ResetDbType ()
+ {
+ throw new NotImplementedException ();
+ }
+
+#endif // NET_2_0
#endregion
}
}
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcParameterCollection.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcParameterCollection.cs
index 27cf61d920a..f3098581c38 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcParameterCollection.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcParameterCollection.cs
@@ -37,16 +37,26 @@ using System.Data;
using System.ComponentModel;
using System.Data.Common;
+#if NET_2_0
+using System.Data.ProviderBase;
+#endif // NET_2_0
+
namespace System.Data.Odbc
{
[ListBindable (false)]
[EditorAttribute ("Microsoft.VSDesigner.Data.Design.DBParametersEditor, "+ Consts.AssemblyMicrosoft_VSDesigner, "System.Drawing.Design.UITypeEditor, "+ Consts.AssemblySystem_Drawing )]
+#if NET_2_0
+ public sealed class OdbcParameterCollection : DbParameterBaseCollection
+#else
public sealed class OdbcParameterCollection : MarshalByRefObject,
IDataParameterCollection, IList, ICollection, IEnumerable
+#endif // NET_2_0
{
#region Fields
+#if ONLY_1_1
ArrayList list = new ArrayList ();
+#endif // ONLY_1_1
#endregion // Fields
@@ -58,7 +68,7 @@ namespace System.Data.Odbc
#endregion // Constructors
#region Properties
-
+#if ONLY_1_1
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public int Count {
@@ -88,7 +98,35 @@ namespace System.Data.Odbc
}
}
+#else
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public new OdbcParameter this[int index] {
+ get { return (OdbcParameter) base[index]; }
+ set { base [index] = value; }
+ }
+ [Browsable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public new OdbcParameter this[string parameterName] {
+ get {
+ foreach (OdbcParameter p in this)
+ if (p.ParameterName.Equals (parameterName))
+ return p;
+ throw new IndexOutOfRangeException ("The specified name does not exist: " + parameterName);
+ }
+ set {
+ if (!Contains (parameterName))
+ throw new IndexOutOfRangeException("The specified name does not exist: " + parameterName);
+ this [IndexOf (parameterName)] = value;
+ }
+
+ }
+
+#endif // ONLY_1_1
+
+
+#if ONLY_1_1
int ICollection.Count {
get { return list.Count; }
}
@@ -124,11 +162,17 @@ namespace System.Data.Odbc
}
}
+#endif // ONLY_1_1
+
+#if NET_2_0
+ protected override Type ItemType { get { return typeof (OdbcParameter); } }
+#endif // NET_2_0
#endregion // Properties
#region Methods
+#if ONLY_1_1
public int Add (object value)
{
if (!(value is OdbcParameter))
@@ -136,7 +180,7 @@ namespace System.Data.Odbc
Add ((OdbcParameter) value);
return IndexOf (value);
}
-
+#endif // ONLY_1_1
public OdbcParameter Add (OdbcParameter parameter)
@@ -145,7 +189,11 @@ namespace System.Data.Odbc
throw new ArgumentException ("The OdbcParameter specified in the value parameter is already added to this or another OdbcParameterCollection.");
parameter.Container = this;
+#if ONLY_1_1
list.Add (parameter);
+#else
+ base.Add ((DbParameter) parameter);
+#endif // ONLY_1_1
return parameter;
}
@@ -178,7 +226,7 @@ namespace System.Data.Odbc
}
}
-
+#if ONLY_1_1
int IList.Add (object value)
{
if (!(value is IDataParameter))
@@ -251,7 +299,9 @@ namespace System.Data.Odbc
{
list.Remove (((IDataParameterCollection) this)[name]);
}
+#endif // ONLY_1_1
+#if ONLY_1_1
public void Clear()
{
foreach (OdbcParameter p in list)
@@ -259,40 +309,82 @@ namespace System.Data.Odbc
list.Clear ();
}
+#else
+ public override void Clear()
+ {
+ foreach (OdbcParameter p in this)
+ p.Container = null;
+
+ base.Clear ();
+ }
+
+#endif // ONLY_1_1
- public bool Contains (object value)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ bool Contains (object value)
{
if (!(value is OdbcParameter))
throw new InvalidCastException ("The parameter was not an OdbcParameter.");
return Contains (((OdbcParameter) value).ParameterName);
}
- public bool Contains (string value)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ bool Contains (string value)
{
- foreach (OdbcParameter p in list)
+ foreach (OdbcParameter p in this)
if (p.ParameterName.Equals (value))
return true;
return false;
}
- public void CopyTo (Array array, int index)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void CopyTo (Array array, int index)
{
+#if ONLY_1_1
list.CopyTo (array, index);
+#else
+ base.CopyTo (array, index);
+#endif //ONLY_1_1
}
- public IEnumerator GetEnumerator()
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ IEnumerator GetEnumerator()
{
+#if ONLY_1_1
return list.GetEnumerator ();
+#else
+ return base.GetEnumerator ();
+#endif // ONLY_1_1
}
- public int IndexOf (object value)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int IndexOf (object value)
{
if (!(value is OdbcParameter))
throw new InvalidCastException ("The parameter was not an OdbcParameter.");
return IndexOf (((OdbcParameter) value).ParameterName);
}
- public int IndexOf (string parameterName)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ int IndexOf (string parameterName)
{
for (int i = 0; i < Count; i += 1)
if (this [i].ParameterName.Equals (parameterName))
@@ -300,24 +392,53 @@ namespace System.Data.Odbc
return -1;
}
- public void Insert (int index, object value)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void Insert (int index, object value)
{
+#if ONLY_1_1
list.Insert (index, value);
+#else
+ base.Insert (index, value);
+#endif // ONLY_1_1
}
- public void Remove (object value)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void Remove (object value)
{
((OdbcParameter) value).Container = null;
+#if ONLY_1_1
list.Remove (value);
+#else
+ base.Remove (value);
+
+#endif // ONLY_1_1
}
- public void RemoveAt (int index)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void RemoveAt (int index)
{
this [index].Container = null;
+#if ONLY_1_1
list.RemoveAt (index);
+#else
+ base.RemoveAt (index);
+#endif // ONLY_1_1
}
- public void RemoveAt (string parameterName)
+ public
+#if NET_2_0
+ override
+#endif // NET_2_0
+ void RemoveAt (string parameterName)
{
RemoveAt (IndexOf (parameterName));
}
diff --git a/mcs/class/System.Data/System.Data.Odbc/OdbcTransaction.cs b/mcs/class/System.Data/System.Data.Odbc/OdbcTransaction.cs
index 74e33cbc444..dcc3b58d2cb 100644
--- a/mcs/class/System.Data/System.Data.Odbc/OdbcTransaction.cs
+++ b/mcs/class/System.Data/System.Data.Odbc/OdbcTransaction.cs
@@ -31,10 +31,20 @@
//
using System;
using System.Data;
+
+#if NET_2_0
+using System.Data.Common;
+#endif // NET_2_0
+
namespace System.Data.Odbc
{
+
+#if NET_2_0
+ public sealed class OdbcTransaction : DbTransaction
+#else
public sealed class OdbcTransaction : MarshalByRefObject, IDbTransaction
+#endif // NET_2_0
{
private bool disposed = false;
private OdbcConnection connection;
@@ -86,16 +96,29 @@ namespace System.Data.Odbc
}
}
+#if ONLY_1_1
void IDisposable.Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
+#else
+ public override void Dispose ()
+ {
+ Dispose (true);
+ GC.SuppressFinalize (this);
+ }
+#endif // ONLY_1_1
+
#endregion Implementation of IDisposable
#region Implementation of IDbTransaction
- public void Commit()
+ public
+#if NET_2_0
+ override
+#endif //NET_2_0
+ void Commit()
{
if (connection.transaction==this)
{
@@ -108,7 +131,11 @@ namespace System.Data.Odbc
throw new InvalidOperationException();
}
- public void Rollback()
+ public
+#if NET_2_0
+ override
+#endif //NET_2_0
+ void Rollback()
{
if (connection.transaction==this)
{
@@ -121,6 +148,7 @@ namespace System.Data.Odbc
throw new InvalidOperationException();
}
+#if ONLY_1_1
IDbConnection IDbTransaction.Connection
{
get
@@ -129,7 +157,19 @@ namespace System.Data.Odbc
}
}
- public IsolationLevel IsolationLevel
+#endif // ONLY_1_1
+#if NET_2_0
+ protected override DbConnection DbConnection
+ {
+ get {return Connection;}
+ }
+#endif // NET_2_0
+
+ public
+#if NET_2_0
+ override
+#endif //NET_2_0
+ IsolationLevel IsolationLevel
{
get
{
@@ -141,6 +181,7 @@ namespace System.Data.Odbc
#region Public Instance Properties
+#if ONLY_1_1
public OdbcConnection Connection
{
get
@@ -149,6 +190,7 @@ namespace System.Data.Odbc
}
}
+#endif // ONLY_1_1
#endregion Public Instance Properties
}
}