[IronPython] Working with System.Data.DataColumn[]
Anthony Tarlano
mailinglist.account at gmail.com
Fri Apr 15 18:25:15 CEST 2005
To all:
Is there anyway to add a System.Data.DataColumn instance to the
PrimaryKey System.Data.DataColumn[] in IronPython??
Please see following code
Thanks in advance..
Anthony
IronPython 0.7.2 on .NET 2.0.40607.42
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import sys
>>> sys.LoadAssemblyByName('System.Data')
>>> #--
()
>>>
()
>>> from System import Type, Console
>>> from System.Data import DataSet, DataColumn
>>> dataset = DataSet('MySet')
>>> dataset.Tables.Add('Order')
Order
>>> dataset.Tables['Order'].Columns.Add('OrderID',
... Type.GetType('System.Int32'))
...
OrderID
>>> dataset.Tables['Order'].Columns.Add('CustomerFirstName',
... Type.GetType('System.String'))
...
CustomerFirstName
>>> dataset.Tables['Order'].Columns.Add('CustomerLastName',
... Type.GetType('System.String'))
...
CustomerLastName
>>> dataset.Tables['Order'].PrimaryKey
System.Data.DataColumn[]()
>>> dataset.Tables['Order'].Columns['OrderID']
OrderID
>>> dataset.Tables['Order'].PrimaryKey[0] = dataset.Tables['Order'].Columns['Ord
erID']
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Array.InternalSetValue(Object value, Int32 index1, Int32 index2, In
t32 index3)
at System.Array.SetValue(Object value, Int32 index)
at IronPython.Objects.ArrayOps.SetIndex(Array a, Object index, Object value)
at IronPython.Objects.Ops.SetIndex(Object o, Object index, Object value)
at IronPython.Objects.Ops.SetIndexStackHelper(Object value, Object o, Object
index)
at input_13.Run(Frame frame)
at IronPython.Hosting.PythonEngine.DoOneInteractive(Frame topFrame)
at IronPython.Hosting.PythonEngine.RunInteractive()
>>>
More information about the Ironpython-users
mailing list