none
How is typed dataset used? RRS feed

  • Question

  •  

    Hi,

     

      I'm trying to make a typed dataset work without sucess. I created two tables in the DataSet (Clients and Cities and the relashionship between Client and City). I read the clients data with no problem with this code:

     

    client = new ClientTableAdapter();

    clientTable = client.GetData();

     

      client connects to the database GetData read its data. In clientTable[0] I have allmost the fields.

     

      In my aplication (WPF interface) I have the field under ClientRow named CityRowByFK_City_City. The problem is that this field is allways null and the cities are not populated.

     

      My simple questions are: What I need to do I need to read the cites list? What code is missing? The City table will be read once to all clients? If there are 5000 cities in the table, all them will be loaded?

     

      Thanks,

     

      Marco Castro

    Monday, September 15, 2008 1:13 AM

Answers

  • Hello Marco,

     

    The ClientTableAdapter.Get data does not include city's data by default.

    If you don't consider the performance, you can use

     

    //  Assume cityTable isin the same dataSet of clientTable,

    cityTA  = new CityTableAdapter();

    cityTable = cityTA.GetData();

     

    Yes, this will load all city data.

     

    However, you can add a LoadCityByClient method to the ClientTableAdapter (throught the dataset designer, or manually)

    then you can load cities on demand, etc...

     

    Hope this help.

     

    John Chen

    Saturday, September 27, 2008 8:25 PM

All replies

  • It is hard to say - but are you saying that the field CityRowByFK_City_City in table Client is always null?  It that field the lookup field (key) into the city table?  If so, it could be that you need to populate this field first before your query will work.

     

    Thursday, September 25, 2008 4:53 PM
  • Hello Marco,

     

    The ClientTableAdapter.Get data does not include city's data by default.

    If you don't consider the performance, you can use

     

    //  Assume cityTable isin the same dataSet of clientTable,

    cityTA  = new CityTableAdapter();

    cityTable = cityTA.GetData();

     

    Yes, this will load all city data.

     

    However, you can add a LoadCityByClient method to the ClientTableAdapter (throught the dataset designer, or manually)

    then you can load cities on demand, etc...

     

    Hope this help.

     

    John Chen

    Saturday, September 27, 2008 8:25 PM