PC Review


Reply
Thread Tools Rate Thread

Type conversion problems with ADO.NET

 
 
Michael Hodgson
Guest
Posts: n/a
 
      10th Sep 2004
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

 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      20th Sep 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" <(E-Mail Removed)> wrote in message
news:41417f81$0$22752$(E-Mail Removed)...
> 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
>



 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion from type 'DBNull' to type 'String' is not valid Cirene Microsoft ASP .NET 2 19th Jun 2008 07:18 AM
problems with type conversion... Brad Pears Microsoft VB .NET 1 10th Jul 2007 07:40 PM
Conversion from type DBNull to type String is invalid Michel Vanderbeke Microsoft VB .NET 4 16th May 2007 01:11 AM
Conversion from type 'DBNull' to type 'String' is not valid Chris Microsoft ASP .NET 2 11th May 2006 10:20 AM
Conversion from type 'SqlInt32' to type 'Integer' is not valid Greg Burns Microsoft ADO .NET 2 1st Nov 2005 12:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:32 PM.