none
[2005] DatSet designer: design question RRS feed

  • Question

  • Hi,

    3 questions pls if u don t mind:

    Sometimes, I have DataTable in my DataSet that returns list of Customers. Each customer has many, many fields ex: Name, Phone, email, Age, Address...etc let s say 10 or 20 fields.


    When I have a GridView or DetailsView...etc, I usually use ObjectDataSource linked to the DataSet queries that return a dataType of type customersDataTable. That s fine since I need all or most of the fileds from Customers table. In order to do that I use: customersTableAdapter

    But, On some pages, I have a DropDownList or ListBox that displays only one or 2 fields from the customersDataTable.

    The problem is that: for the DropDownList or the ListBox I don t need all the fields of CustomersDataTable, therefore, I am not gonna use a query that returns type: CustomersDataTable because such query d return many fields that I dont need and represents a performance hit (don t u agree).

    My 1st question therefore is:

    1 - What do I do in this case: how do I design my DataSet datatable or query in order to retrun only the 2 or 3 fileds that I need for display on the dropdownlist or listbox? Should I use the customersTableAdapter itself (which is performance hit since it generates all fields) or create a new tableadapter with only the fields that I need for the Bound Control or what s a good practice for this issue?

    2 - My second question: in case I need to generate a report for example and I need fields from all over the tables, let s say: 3 or 4 tables. How do I use the dataset designer in order to generate data type (dataTable) for example, that returns all that mix of fields for generating my report? For example, in the case or a report that generates data related to customers but also gets data from other tables, should I use the customersTableAdapter itself or create a new tableadapter with all the fields I need for the report or what s a good practice for this issue?

    3- My last question pls, re u aware of any document or video or lab that goes deep in these dataset or dataset designer design considerations?
    __________________
    Thanks a lot for your help.
    Wednesday, January 9, 2008 4:51 PM

Answers

  • EDIT

     

    These are not design issues just implementation issues for question number one go to the T-SQL forum to get either a stored procedure or sql statement that will populate the DDL and Lisbox. There are known issues with Listbox so you may need to post that at the datacontrols forum at Asp.net but controls people don't know data so you need to get the sql statement that will return the data you need first.

     

    Question number 2 depends on the number of columns per report and tables to locate the columns under ten tables write one stored procedures or sql statement to generate the report.  If 50 columns or more in fifty tables create a view for the report and use the view as your datasource.  If the reports are very complicated you may need to ask for time to design the reports before development so your code will not blow in production.

     

    Try to get a good SQL Server programming book so you think of data in columns and not rows so you don't see complications where none exists.


    If you want ObjectDatasource doing advanced stuff check out Eilon Lipton's blog and the thread below for known issues.

     


    http://weblogs.asp.net/leftslipper/archive/tags/objectdatasource/default.aspx


    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2419916&SiteID=1

     

     

    This thread is not a WinForm or WebForm question but rather better use of the data tools available in the .NET framework for application development. That is the reason the DataSet comes with the Command objects.

    Wednesday, January 9, 2008 6:19 PM