none
DataTable from designer - instance RRS feed

  • Question

  • If I created a dataset and dragged tables from server explorer. When it comes time to call the fill method of the tableadapter, one of the params is the table. Is there an instance already of the table? The example makes it look like there is:

    customersTableAdapter.FillByCityAndState(northwindDataSet.Customers, "Seattle", "WA");

    However, mine has no such member:

    taBSCENARIO.FillByYear(

    budgetDataSet.BSCENARIO, fromYear, toYear);

    BSCENARIO (the table) does not exist as a member of budgetDataSet (the data set)

    Was there some property you had to set to have the designer create you an instance and make it accessable?



    Monday, December 7, 2009 5:05 PM

Answers

  • Through trial and error I found out that when you instantiate a dataset it instantiates its tables.
    You cannot get an instance of a table simply by using the dataset name, you must use an instance of the dataset.

    To most that would seem obvious, but being new to datasets and .NET in general, not so much.
    Wednesday, December 9, 2009 1:11 AM

All replies

  • BSCENARIO is the name of the class inside of the strongly typed TableAdapter. This is not the actual DataTable name inside of the DataSet. You could inspect generated code to see where it's created. TableAdapter is just a generated code wrapper, not really a DataSet or DataTable
    Val Mazur (MVP) http://www.xporttools.net
    Tuesday, December 8, 2009 11:29 AM
    Moderator
  • Through trial and error I found out that when you instantiate a dataset it instantiates its tables.
    You cannot get an instance of a table simply by using the dataset name, you must use an instance of the dataset.

    To most that would seem obvious, but being new to datasets and .NET in general, not so much.
    Wednesday, December 9, 2009 1:11 AM