Question

I have a DataSet named BillMat.xsd

BillMat Dataset

When my application loads, a module fills that dataset's DataTable DataTable with the correct information.

My question is ... How can I access that DataTable's already filled information from another form?


Here's how I tried to access it on one of my forms:

Dim View As New DataView
View.Table = BillMat.Tables("dtBillHeader")

But I get the following error:

Non Shared

If I create a new instance of my dataset and store it in a variable, I'll be able to get rid of this error message but it will also get rid of all my data in my dataset's datatables ... Is there a way to access a DataTable's information from another form?

Was it helpful?

Solution

You need to fix it so both forms are referencing the same DataSet or DataTable object. If one is a "child" form of the other, such as a dialog, you can pass it from the parent to the child via a property. Otherwise, ideally, the same data object would be injected into both forms by some third object which created both of the forms. Short of all that, you could create a singleton or global variable, but please don't!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top