Hello,

Hoping someone here can help me...

I'm trying to use a DataSet built from a number of different sources,
and build some relationships between the constituent tables.

The first table basically consists of:

CatID,Description

and the second is

CatID,TileID

The problem is that CatID in the first table is Int16 (short) and CatID
in the second table is Int32. As a result I can't create a datarelation
between the two CatID columns.

I cannot change the table definition for Table1(format is specified by
the client) to make both CatID columns Int32, and it seems you cannot
change the DataType of a column once it's loaded with data - short of
creating a new DataTable in memory with the new schema and copying the
rows across one at a time. Is there another way?

The source database for Table1 is Access 2000 and it's being accessed
via OleDB. Inside Access you can do something like:

SELECT clng(CatID), Description

but this unsuprisingly fails when called via. the OleDB provider.

I believe functions like CAST and CONVERT exist for big brother
SQL-SERVER, but I cannot come up with a syntax that seems to work for my
Access DB.

There must be a way of getting a Column of Int16 numbers from Access
into a DataTable as Int32?

-Michael

Re: Type conversion problems with ADO.NET by Miha

Miha
Mon Sep 20 01:51:42 CDT 2004

Hi Micheal,

Create table with right column types before you fill it and then fill it :-)

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Michael Hodgson" <news@mellowmole.com> wrote in message
news:41417f81$0$22752$db0fefd9@news.zen.co.uk...
> Hello,
>
> Hoping someone here can help me...
>
> I'm trying to use a DataSet built from a number of different sources,
> and build some relationships between the constituent tables.
>
> The first table basically consists of:
>
> CatID,Description
>
> and the second is
>
> CatID,TileID
>
> The problem is that CatID in the first table is Int16 (short) and CatID in
> the second table is Int32. As a result I can't create a datarelation
> between the two CatID columns.
>
> I cannot change the table definition for Table1(format is specified by the
> client) to make both CatID columns Int32, and it seems you cannot change
> the DataType of a column once it's loaded with data - short of creating a
> new DataTable in memory with the new schema and copying the rows across
> one at a time. Is there another way?
>
> The source database for Table1 is Access 2000 and it's being accessed via
> OleDB. Inside Access you can do something like:
>
> SELECT clng(CatID), Description
>
> but this unsuprisingly fails when called via. the OleDB provider.
>
> I believe functions like CAST and CONVERT exist for big brother
> SQL-SERVER, but I cannot come up with a syntax that seems to work for my
> Access DB.
>
> There must be a way of getting a Column of Int16 numbers from Access into
> a DataTable as Int32?
>
> -Michael
>