Pārlūkot izejas kodu

2007-02-02 Amit Biswas <[email protected]>

	* OdbcInfoMessageEventArgs.cs (ToString): Implemented new method.

	* OdbcParameterCollection.cs (AddRange, Insert, AddWithValue)
	(Remove, Contains, CopyTo): Implemented missing .NET 2.0 methods.

	* OdbcMetaDataCollectionNames.cs: Added new class for .NET 2.0
	profile.

	* OdbcMetaDataCollectionNames.cs (Equals): Implemented overloads
	methods.

2007-02-02  Nidhi Rawal  <[email protected]>

	* libodbc.cs: Imported a dll file for char datatype.
	
	* OdbcDataReader.cs (GetChar): Implemented the method and wrote
	a switch case for char data type in GetValue method..
	(GetDecimal): Implemented the method.
	
	* OdbcConnectionStringBuilder.cs: Written the new class.

	* OdbcMetaDataColumnNames.cs: Written the new class.

	* OdbcFactory.cs (CreateConnectionStringBuilder): Implemented the method.

	* OdbcParameterCollection.cs (IndexOf): Implemented the method.


svn path=/trunk/mcs/; revision=73235
Nagappan Alagappan 19 gadi atpakaļ
vecāks
revīzija
f4eba8efe6

+ 29 - 0
mcs/class/System.Data/System.Data.Odbc/ChangeLog

@@ -1,3 +1,32 @@
+2007-02-02  Amit Biswas <[email protected]>
+
+	* OdbcInfoMessageEventArgs.cs (ToString): Implemented new method.
+
+	* OdbcParameterCollection.cs (AddRange, Insert, AddWithValue)
+	(Remove, Contains, CopyTo): Implemented missing .NET 2.0 methods.
+
+	* OdbcMetaDataCollectionNames.cs: Added new class for .NET 2.0
+	profile.
+
+	* OdbcMetaDataCollectionNames.cs (Equals): Implemented overloads
+	methods.
+
+2007-02-02  Nidhi Rawal  <[email protected]>
+
+	* libodbc.cs: Imported a dll file for char datatype.
+	
+	* OdbcDataReader.cs (GetChar): Implemented the method and wrote
+	a switch case for char data type in GetValue method..
+	(GetDecimal): Implemented the method.
+	
+	* OdbcConnectionStringBuilder.cs: Written the new class.
+
+	* OdbcMetaDataColumnNames.cs: Written the new class.
+
+	* OdbcFactory.cs (CreateConnectionStringBuilder): Implemented the method.
+
+	* OdbcParameterCollection.cs (IndexOf): Implemented the method.
+
 2007-02-09  Nagappan A  <[email protected]>
 
 	* OdbcDataReader.cs (GetDecimal): Implemented new API.

+ 118 - 0
mcs/class/System.Data/System.Data.Odbc/OdbcConnectionStringBuilder.cs

@@ -0,0 +1,118 @@
+//
+// System.Data.Odbc.OdbcConnectionStringBuilder
+//
+// Authors: 
+//	  Nidhi Rawal ([email protected])
+//
+// Copyright (C) 2007 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;
+using System.Text;
+using System.Reflection;
+using System.Collections;
+using System.ComponentModel;
+using System.Collections.Generic;
+
+using System.Data;
+using System.Data.Common;
+using System.Data.Odbc;
+
+namespace System.Data.Odbc
+{
+	public sealed class OdbcConnectionStringBuilder : DbConnectionStringBuilder
+	{
+		#region Fields
+		Dictionary<string, object> _dictionary = null;	
+		#endregion // Fields		
+
+		#region Constructors
+		public OdbcConnectionStringBuilder ()
+		{
+			Init();
+		}
+        
+		[MonoTODO]       
+		public OdbcConnectionStringBuilder (string connectionString)
+		{
+			throw new NotImplementedException();
+		}
+
+		private void Init ()
+		{
+			_dictionary = new Dictionary<string, object> ();
+		}
+		#endregion // Constructors
+
+		#region Properties
+		public override Object this [string keyword]
+		{
+			get
+			{
+				if (ContainsKey (keyword))
+					return _dictionary [keyword];
+				else
+					throw new ArgumentException ();
+			}
+			set { _dictionary.Add (keyword, value); }
+		}
+                
+		public override ICollection Keys
+		{
+			get { return _dictionary.Keys; }
+		}
+		#endregion // Properties
+
+		#region Methods
+		public override bool ContainsKey (string keyword)
+		{
+			return _dictionary.ContainsKey (keyword);
+		}
+                
+		public override bool Remove (string keyword)
+		{
+			return _dictionary.Remove (keyword);
+		}
+
+		public override void Clear()
+		{
+			_dictionary.Clear ();
+		}
+
+		public override bool TryGetValue (string keyword, out Object value)
+		{
+			bool found = false;
+			if (_dictionary.ContainsKey (keyword)) {
+				found = true;
+			value = this [keyword];
+			}
+			else {
+			value = null;
+			found = false;
+			}
+			return found;
+		}
+		#endregion // Methods
+	}
+}
+#endif // NET_2_0 using

+ 6 - 2
mcs/class/System.Data/System.Data.Odbc/OdbcDataReader.cs

@@ -318,14 +318,13 @@ namespace System.Data.Odbc
                         return returnVal;
 		}
 		
-		[MonoTODO]
 		public 
 #if NET_2_0
 		override
 #endif // NET_2_0
 		char GetChar (int ordinal)
 		{
-			throw new NotImplementedException ();
+			return (char) GetValue (ordinal);
 		}
 
 		[MonoTODO]
@@ -710,6 +709,11 @@ namespace System.Data.Odbc
 					} while (ret != OdbcReturn.NoData);
 					DataValue = sb1.ToString ();
 					break;
+				case OdbcType.Char:
+					char charData = ' ';
+					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref charData, 0, ref outsize);
+					DataValue = charData;
+					break;
 				case OdbcType.Real:
 					float float_data = 0;
 					ret = libodbc.SQLGetData (hstmt, ColIndex, col.SqlCType, ref float_data, 0, ref outsize);

+ 4 - 4
mcs/class/System.Data/System.Data.Odbc/OdbcFactory.cs

@@ -92,10 +92,10 @@ namespace System.Data.Odbc
                 }
                 
                 
-//                 public override DbConnectionStringBuilder CreateConnectionStringBuilder()
-//                 {
-//                         throw new NotImplementedException ();
-//                 }
+                 public override DbConnectionStringBuilder CreateConnectionStringBuilder()
+                 {
+                         return new OdbcConnectionStringBuilder () as DbConnectionStringBuilder;
+                 }
                 
                 public override DbDataAdapter CreateDataAdapter()
                 {

+ 9 - 9
mcs/class/System.Data/System.Data.Odbc/OdbcInfoMessageEventArgs.cs

@@ -35,13 +35,13 @@ using System.Data.Common;
 
 namespace System.Data.Odbc
 {
-	public sealed class OdbcInfoMessageEventArgs : EventArgs 
-	{
-		#region Constructors
-
-		internal OdbcInfoMessageEventArgs() {
-		}
-
+	public sealed class OdbcInfoMessageEventArgs : EventArgs
+	{
+		#region Constructors
+
+		internal OdbcInfoMessageEventArgs() {
+		}
+
 		#endregion Constructors
 
 		#region Properties
@@ -61,10 +61,10 @@ namespace System.Data.Odbc
 
 		#region Methods
 
-		[MonoTODO]
+		
 		public override string ToString ()
 		{
-			throw new NotImplementedException ();
+			return GetType ().FullName;
 		}
 
 		#endregion // Methods

+ 72 - 0
mcs/class/System.Data/System.Data.Odbc/OdbcMetaDataCollectionNames.cs

@@ -0,0 +1,72 @@
+//
+// System.Data.Odbc.OdbcMetaDataCollectionNames
+//
+// Author:
+//   Amit Biswas ([email protected])
+//
+// Copyright (C) Novell Inc, 2007
+//
+
+//
+// Copyright (C) 2007 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.
+//
+
+using System.Text;
+using System.Data;
+using System.Data.Common;
+using System.ComponentModel;
+
+namespace System.Data.Odbc
+{
+	/// <summary>
+	/// Provides a list of constants which can be used with the GetSchema method to retrieve metadata collections.
+	/// </summary>
+	/// 
+
+#if NET_2_0
+	public static class OdbcMetaDataCollectionNames
+	{
+	#region Fields
+
+		#endregion // Fields
+
+
+		#region Methods
+
+		public virtual bool Equals (Object obj)
+		{
+			return (this == obj);
+		}
+
+		public static bool Equals (Object o1, Object o2)
+		{
+			if (o1 == o2 || (o1 != null && o1.Equals (o2) == true))
+				return true;
+			else
+				return false;
+		}
+
+		#endregion // Methods
+	}
+#endif // NET_2_0
+
+}

+ 63 - 0
mcs/class/System.Data/System.Data.Odbc/OdbcMetaDataColumnNames.cs

@@ -0,0 +1,63 @@
+//
+// System.Data.Odbc.OdbcMetaDataColumnNames
+//
+// Author: Nidhi Rawal ([email protected])
+//  
+//  
+//  
+//
+// Copyright (C) Brian Ritchie, 2007
+// Copyright (C) Daniel Morgan, 2007
+//
+
+//
+// Copyright (C) 2007 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.
+//
+
+using System.Collections;
+using System.ComponentModel;
+using System.Data;
+using System.Data.Common;
+using System.Text;
+
+namespace System.Data.Odbc
+{
+	public static class OdbcMetaDataColumnNames
+	{
+		#region Fields
+
+		public static readonly string BooleanFalseLiteral;
+		public static readonly string BooleanTrueLiteral;
+		public static readonly string SQLType;
+
+		#endregion
+
+		#region Methods
+        
+		public static bool ReferenceEquals(Object o1, Object o2)
+		{
+			return o1 == o2;
+		}
+
+		#endregion
+	}
+}

+ 82 - 3
mcs/class/System.Data/System.Data.Odbc/OdbcParameterCollection.cs

@@ -286,6 +286,8 @@ namespace System.Data.Odbc
 #endif // NET_2_0
                 void Insert (int index, object value)
                 {
+			if (index > list.Count || index < 0)
+				throw new ArgumentOutOfRangeException("index", "The index must be non-negative and less than or equal to size of the collection");
                         list.Insert (index, value);
                 }
                                                                                                     
@@ -319,6 +321,7 @@ namespace System.Data.Odbc
                 }
 
 
+
 #if NET_2_0
 		[MonoTODO]
 		protected override DbParameter GetParameter (string name)
@@ -344,13 +347,89 @@ namespace System.Data.Odbc
 			throw new NotImplementedException ();
 		}
 
-		[MonoTODO]
+
 		public override void AddRange (Array values)
 		{
-			throw new NotImplementedException ();
+			if (values == null)
+				throw new ArgumentNullException ("Value cannot be null");
+			foreach (OdbcParameter p in values) {
+				if (p == null)
+					throw new ArgumentNullException ("The OdbcParameterCollection only accepts non-null OdbcParameter type objects");
+				for (int j = 0; j < list.Count; j++) {
+					if (p.Equals (list [j]))
+						throw new ArgumentException ("The OdbcParameter is already contained by another OdbcParameterCollection");
+				}
+				Insert (list.Count, p);
+			}
+		}
+
+		public void AddRange (OdbcParameter [] values)
+		{
+			if (values == null)
+				throw new ArgumentNullException ("Value cannot be null");
+			for (int i = 0; i < values.Length; i++) {
+				if (values [i] == null)
+					throw new ArgumentNullException ("The OdbcParameterCollection only accepts non-null OdbcParameter type objects");
+				for (int j = 0; j < list.Count; j++) {
+					if (values [i].Equals (list [j]))
+						throw new ArgumentException ("The OdbcParameter is already contained by another OdbcParameterCollection");
+				}
+				Insert (list.Count, values [i]);
+			}
+		}
+
+		public void Insert (int index, OdbcParameter value)
+		{
+			if (index > list.Count || index < 0)
+				throw new ArgumentOutOfRangeException ("index", "The index must be non-negative and less than or equal to size of the collection");
+			list.Insert (index, value);
+		}
+
+		public OdbcParameter AddWithValue (string parameterName, Object value)
+		{
+			if (parameterName == null || value == null)
+				throw new ArgumentNullException ("Argument cannot be null");
+			return Add (new OdbcParameter (parameterName, value));
+		}
+
+		public void Remove (OdbcParameter value)
+		{
+			if (value == null)
+				throw new ArgumentNullException("Value cannot be null");
+			value.Container = null;
+			list.Remove (value);
+		}
+
+		public bool Contains (OdbcParameter value)
+		{
+			if (value == null)
+				throw new ArgumentNullException ("Value cannot be null");
+			return Contains (value.ParameterName);
+		}
+
+		public int IndexOf (OdbcParameter value)
+		{
+			if (value == null)
+				throw new ArgumentNullException("Value cannot be null");
+			return list.IndexOf ((object) value);
+		}
+
+		public void CopyTo (OdbcParameter [] array, int index)
+		{
+			if (array == null)
+				throw new NullReferenceException ("Object reference not set to an instance of an object");
+			if (array.Rank != 1)
+				throw new ArgumentException ("Only single dimensional arrays are supported for the requested action");
+			if (index < array.GetLowerBound (0))
+				throw new ArgumentOutOfRangeException ("index", "The specified number is less than the array's lower bound in the first dimension");
+			if (index > array.GetUpperBound (0) || index + list.Count > array.Length)
+				throw new ArgumentException ("The destination array was not long enough, check destination array index, length and lower bounds");
+			foreach (OdbcParameter p in list) {
+				array [index++] = p;
+			}
 		}
 #endif
 		#endregion // Methods
 
-	}
+			}
 }

+ 3 - 0
mcs/class/System.Data/System.Data.Odbc/libodbc.cs

@@ -233,6 +233,9 @@ namespace System.Data.Odbc
 		[DllImport("odbc32.dll")]
 		internal static extern OdbcReturn SQLGetData (IntPtr StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, byte[] TargetPtr, int BufferLen, ref int Len);
 
+		[DllImport("odbc32.dll")]
+		internal static extern OdbcReturn SQLGetData (IntPtr StatementHandle, ushort ColumnNumber, SQL_C_TYPE TargetType, ref char TargetPtr, int BufferLen, ref int Len);
+
 		[DllImport("odbc32.dll")]
 		internal static extern OdbcReturn SQLDescribeCol(IntPtr StatementHandle, ushort ColumnNumber, byte[] ColumnName, short BufferLength, ref short NameLength, ref short DataType, ref uint ColumnSize, ref short DecimalDigits, ref short Nullable);