Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with the dataset

Status
Not open for further replies.

lutzs

Programmer
Oct 8, 2002
75
LU
Hi,

i have a Dataset (dataSet) and two tables there:
table "I_ABC" and "RESULT"
The table RESULT has two columns: ID and STH
The table RESULT is my output table and i will load
the column of I_ABC in my table RESULT:
I_ABC.ID > RESULT.ID

This is my code:

foreach(DataRow dr in dataSet.I_ABC)
{
DataRow newRow;
newRow = result.NewRow();
newRow[0] = dataSet.I_CUS.Columns["ID"];
//newRow["Bestand"] = "bestand";
ergebnis.Rows.Add(newRow);
}

myDataView = new DataView(result);
dataGrid1.DataSource = myDataView;

The values of I_ABC are from an oracle table.
There is the datatype of "ID": numeric.
In my DataSet (I've dropped the table from the dataconnection to my dataSet) is the datatype: decimal.
I create columns of the table RESULT as:

myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.Int32");
myDataColumn.ColumnName = "ID";
myDataColumn.AllowDBNull = true;
myDataColumn.Unique = true;

result.Columns.Add(myDataColumn);

myDataColumn = new DataColumn();
myDataColumn.DataType = Type.GetType("System.In32");
myDataColumn.ColumnName = "Bestand";
myDataColumn.AllowDBNull = true;

result.Columns.Add(myDataColumn);

I get this error message:

An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll

Additional information: System.InvalidCastException: Specified cast is not valid.
at System.Convert.ToInt32(Object value)
at System.Data.Common.Int32Storage.Set(Int32 record, Object value)
at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <ID> in ID Column. Expected type is Int32.

What's wrong? What can I do?

Thanks,
Stephanie

 
You have

myDataColumn.DataType = Type.GetType(&quot;System.In32&quot;);

and you need &quot;System.Int32&quot;.

I hope this help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top