No Implicit Conversion For Strongly Typed DataSet In VS2005

A

Andrew Hayes

I'm converting a C#.NET project that was originally written using VS2003 to
VS2005, and on the whole everything has gone well, except for the XSD
DataSets.

I have a class, SmartDataSet, defined as

public class SmartDataSet : DataSet

which has a few extra methods and properties.

I also have a dataset, PartDataSet, which is just a DataTable and 3 columns,
with 2 queries; FetchPartByPartNumber and FetchPartByStockLevel.

In VS2003, the following code is fine:

public SmartDataSet FetchDataSet( object Criteria )
{
ArrayList array = (ArrayList)Criteria;
switch( (string)array[0] )
{
case "PartNumber":
return FetchPartByPartNumber( (string)array[1] );

case "StockLevel":
return FetchPartByStockLevel( (int)array[1] );

default:
throw new Exception( "Invalid criteria supplied" );
}
}

However, in VS2005 it throws a compile error saying it cannot implicitly
convert type PartDataSet to SmartDataSet.

I tried changing the PartDataSet.Designer.cs to use SmartDataSet instead of
global::System.Data.DataSet in the class definition, but then I got a "No
overload for method 'SmartDataSet' takes '3' arguments" error.

Considering that is an auto-generated file, I'd rather not be playing around
with it when it'll just get overwritten the next time it runs the
MSDataSetGenerator custom tool.

Can anyone offer some advice on this?
 
M

Mr. Arnold

Andrew Hayes said:
However, in VS2005 it throws a compile error saying it cannot implicitly
convert type PartDataSet to SmartDataSet.

I tried changing the PartDataSet.Designer.cs to use SmartDataSet instead
of
global::System.Data.DataSet in the class definition, but then I got a "No
overload for method 'SmartDataSet' takes '3' arguments" error.

Considering that is an auto-generated file, I'd rather not be playing
around
with it when it'll just get overwritten the next time it runs the
MSDataSetGenerator custom tool.

PartDataSet.Designer.cs is a 'partial' class is it not?

Maybe, you can extend the Designer.cs with your own 'partial' class. The
Designer.cs get's auto-generated, but your 'partical' class is static that
will have your code to return a SmartDataSet.

http://www.devx.com/dotnet/Article/22603



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4142 (20090609) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
L

Li Huan

PartDataSet.Designer.cs  is a 'partial' class is it not?

Maybe, you can extend the Designer.cs with your own 'partial' class. The
Designer.cs get's auto-generated, but your 'partical' class is static that
will have your code to return a SmartDataSet.

http://www.devx.com/dotnet/Article/22603

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4142 (20090609) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

Go to the designer and double click on the DataTable in the
SmartDataSet. The partial class should be automatically created. Then
add a constructor for the DataSet taking 3 arguments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top