PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET DataType Quandry

Reply

DataType Quandry

 
Thread Tools Rate Thread
Old 29-06-2003, 01:12 AM   #1
Javed
Guest
 
Posts: n/a
Default DataType Quandry


I found a way to handle it. Thanks
Javed


>-----Original Message-----
>Using SQLDataReader, I am trying to read complete rows

of
>data as opposed to reading individual columns like a
>chicken (peck, peck, peck)
>
>using the GetSchemaTable method of the Reader, I add
>columns to my table which will receive the data as
>follows:
>
>SchemaTable = myReader.GetSchemaTable()
>For Each aRow In SchemaTable.Rows
> dt.Columns.Add(aRow("ColumnName").ToString(), aRow
>("datatype"))
>Next
>
>I then use the following loop to read the data into my
>table, dt:
>
>While myReader.Read
> MyRow = dt.NewRow
> For Each aRow In SchemaTable.Rows
> MyRow(aRow("ColumnName").ToString) = myReader.Item
>(aRow("ColumnName").ToString)
> Next
> dt.Rows.Add(MyRow)
>End While
>
>Everything seems to work fine until I try to create a
>DataRelation with a Manually created Child table. Child
>table has a column added as follows:
>
>ChildTbl.Columns.Add("insf_id", GetType(System.Int32))
>
>The parent table read above using the DataReader also

has
>a column, "insf_id" of Type System.int32. But when I
>create the DataRelation, I get the error:
>
>"Parent columns and Child columns don't have type-
>matching columns."
>
>I cannot figure out what I doing wrong. To get the
>datatype from the schematable, I have also used:
>
>dt.Columns.Add(aRow("ColumnName").ToString(),
>System.Type.GetType(aRow("datatype").fullname))
>
>but to no avail. I would appreciate any help.
>
>Javed
>
>.
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off