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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strongly typed dataset error

Status
Not open for further replies.

isaacd

Programmer
Jun 27, 2008
1
US
I have a strongly typed dataset which is not performing like it supposed to.

The error I am getting is:

Code:
'Store_Eco.Inventory_846.newInventoryDS' is a 'field' but is used like a 'type'

I am declaring a new DS as follows:
Code:
[teal]InventoryDS[/teal] newInventoryDS = [blue]new[/blue] [teal]InventoryDS[/teal]();

Then, when I try to use it on the next line as following:

Code:
[u]newInventoryDS[/u].productData prodDT = newInventoryDS.productData.NewproductDataRow();

The error comes up when I try a build.

Oddly newInventoryDS also doesn't come up in intellisense after a few minutes of typing it. It only does sometimes.

I've done the same thing before and not had this issue on a totally different project at my last job.

Could it be a configuration issue or is the DS defined bad?

The DS definition was built from a DTD file passed from a third party. I used Visual Studio then to create the schema and then xsd.exe to create the class. I can create an empty copy and it will write out the xmlSchema just fine also.

Any suggestions?

 
As the error message said, you're using the newInventoryDS object as a type.
Code:
[COLOR=red]
[u]newInventoryDS.productData[/u] prodDT = newInventoryDS.productData.NewproductDataRow(); [COLOR=green]//compile error
[/color][/color]
newInventoryDS.productData is actually a strongly typed DataTable object, and the NewproductDataRow() method is a member of that dataTable type which returns a strongly typed datarow. The strongly typed datatable(s) and datarow(s) are nested types in the InventoryDS dataset type.
Code:
InventoryDS.<the_product_datatable_type> tbl = new InventoryDS.<the_product_datatable_type>();

InventoryDS.<the_product_datarow_type> row = tbl.NewproductDataRow();

hth [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top