2004-03-10 Umadevi S (sumadevi@novell.com)
[mono.git] / mcs / class / System.Data / System.Data / DataTableCollection.cs
index 3c302444a285ef2b2b4e4a4297f761b4531abd1e..f4fbf6a0901df0efcfa10ce7448bcb9adac75664 100644 (file)
@@ -49,6 +49,13 @@ namespace System.Data {
                        }
                }
 
+#if NET_1_2
+               [MonoTODO]
+               public DataTable this [string name, string tbNamespace] {
+                       get { throw new NotImplementedException (); }
+               }
+#endif
+
                protected override ArrayList List {
                        get { return list; }
                }
@@ -81,9 +88,16 @@ namespace System.Data {
                                NameTable (table);
                    
                        // check if the collection has a table with the same name.
-                       if(Contains(table.TableName))
-                               throw new DuplicateNameException("A DataTable named '" + table.TableName + "' already belongs to this DataSet.");
-                               
+                       int tmp = IndexOf(table.TableName);
+                       // if we found a table with same name we have to check
+                       // that it is the same case.
+                       // indexof can return a table with different case letters.
+                       if (tmp != -1)
+                       {
+                               if(table.TableName == this[tmp].TableName)
+                                       throw new DuplicateNameException("A DataTable named '" + table.TableName + "' already belongs to this DataSet.");
+                       }
+       
                        list.Add (table);
                        table.dataSet = dataSet;
                        OnCollectionChanged (new CollectionChangeEventArgs (CollectionChangeAction.Add, table));
@@ -96,6 +110,15 @@ namespace System.Data {
                        return table;
                }
 
+#if NET_1_2
+               public virtual DataTable Add (string name, string tbNamespace)
+               {
+                       DataTable table = new DataTable (name, tbNamespace);
+                       this.Add (table);
+                       return table;
+               }
+#endif
+
                public void AddRange (DataTable[] tables) 
                {
                        foreach (DataTable table in tables)
@@ -242,7 +265,7 @@ namespace System.Data {
                                // loop on all constrains in the current table
                                while (constraintEnumerator.MoveNext())
                                {
-                                       Object o = (Constraint) constraintEnumerator.Current;
+                                       Object o = constraintEnumerator.Current;
                                        // we only check ForeignKeyConstraint
                                        if (o is ForeignKeyConstraint)
                                        {