in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

How to fill data with parameters

Last post 11-08-2007 1:48 PM by vbogey. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 10-18-2006 9:35 AM

    How to fill data with parameters

    Hi,
    I have typed dataset (SQL Server 2000, database Northwind) with one data
    table with SelectComand: dbo.CustOrdersDetail - StoredProcedure. It takes
    one parametr @OrderId

    This dataset is source of C1DataViewSet. Of course I can't use AutoFetch
    because C1DataViewSet is unable to fill data without parameter @OrderId :-(

    Well, in Form.Load event I fill BaseTable manually:
    Dim ta As New NorthwindDataSetTableAdapters.CustOrdersDetailTableAdapter
    ta.Fill(NorthwindDataSet.CustOrdersDetail, 10260)

    And now
    C1DataViewSet1.Views(0).BaseTables(0).Rows.Count returns 4 BUT
    C1DataViewSet1.Views(0).Count is still 0.

    I think, that in earlier versions of C1DataViewSet this works fine.
    (Now I use C1DataExtender.2_2.0.20063.38)

    How to manage this situation correctly?

    Thanks

    ViktorS

    (Of course, that I need more complex StoredProcedure with parameters)
  • 10-18-2006 1:40 PM In reply to

    Re: How to fill data with parameters

    Hi Victor
     
    > Hi,
    > I have typed dataset (SQL Server 2000, database Northwind) with one data
    > table with SelectComand: dbo.CustOrdersDetail - StoredProcedure. It takes
    > one parametr @OrderId
    >
    > This dataset is source of C1DataViewSet. Of course I can't use AutoFetch
    > because C1DataViewSet is unable to fill data without parameter @OrderId :-(
    >
    > Well, in Form.Load event I fill BaseTable manually:
    > Dim ta As New NorthwindDataSetTableAdapters.CustOrdersDetailTableAdapter
    > ta.Fill(NorthwindDataSet.CustOrdersDetail, 10260)
    >
    > And now
    > C1DataViewSet1.Views(0).BaseTables(0).Rows.Count returns 4 BUT
    > C1DataViewSet1.Views(0).Count is still 0.
    >
    > I think, that in earlier versions of C1DataViewSet this works fine.
    > (Now I use C1DataExtender.2_2.0.20063.38)
     
    Internally C1DataView operates in two modes - database mode and in-memory mode. These modes are being selected automatically - if all the base DataTables of the view has TableAdapters then view operates in the database mode, which means that view performs a data fetching from a server and doesn't show the rowset until the fetch will be performed.
    If one of the base tables has no a TableAdapter then view can't fetch a data from server and just exposes a rowset based on what the base table rowsets contain - this case is referred to as in-memory mode, and this is what you need.
    Unfortunately C1DataView has no a public property that allows manually select a necessary mode - I hope we'll add it in the nearest future.
    The only workaround I see for now is the following. You may create a table (say CustOrdersDetailInMemory) in the DataSet with the same structure as CustOrdersDetail, but without a TableAdapter, and define C1DataView so as to represent the CustOrdersDetailInMemory. In run-time you fill the CustOrdersDetail and copy its rows to CustOrdersDetailInMemory:
    foreach (DataRow row in CustOrdersDetail)
       CustOrdersDetailInMemory.Rows.Add(row.ItemArray);
    You can't fill the CustOrdersDetailInMemory table directly because of the CustOrdersDetailTableAdapter.Fill() method has typed parameters. But in the same time the CustOrdersDetailTableAdapter class has the private Adapter property, which returns a non-typed DbAdapter (see its definition in the NorthwindDataSet.Designer.vb file). Because the CustOrdersDetailTableAdapter class is defined as "partial", you may add the public property (say PublicAdapter) in the custom part of NorthwindDataSet (NorthwindDataSet.vb file) which just returns a value of the private Adapter property, and use the PublicAdapter.Fill() method to fill the CustOrdersDetailInMemory directly - this should work because Adapter is non-typed and the structures of the tables are the same.
     
    Thanks,
    Alex

    >
    > How to manage this situation correctly?
    >
    > Thanks
    >
    > ViktorS
    >
    > (Of course, that I need more complex StoredProcedure with parameters)
    >
    > --------------------------------------------------------------------------------
    > http://home.componentone.com/cs/forums/187699/ShowPost.aspx
    >
    >
  • 10-19-2006 4:24 AM In reply to

    Re: How to fill data with parameters

    Hi Alex,
    I am afraid, that all this makes C1DataExtender unusable for me.
    When I use complex column, C1DataViewSet does not use server side filtering (though I think, that is not necessary). Well, I must use filtering in TableAdapter (if I don't want make time wasting applications). Use of suggested model works, but most of elegance of using C1DataExtender is away (simple updates ... )
    I'm not familiar with internal and maybe, that I use C1DataExtender in a bad way.
    I need to display in C1TrueDBGrid relative small subset of SQL Server table with column which is calculated by very complex SQL stored function. Then I need edit this souce table and its related tables and refresh the result of calculated column.
    At this moment I see only solution in use C1DataExtender for managing data in "base tables" and use unbound column in C1TrueDBGrid and calculate data for each row.
    Do You see any better solution?
     
    Thanks
     
    ViktorS
     
     
    <C1_AlexI> píše v diskusním příspěvku news:187715@test.componentone.com...
    Hi Victor
     
    > Hi,
    > I have typed dataset (SQL Server 2000, database Northwind) with one data
    > table with SelectComand: dbo.CustOrdersDetail - StoredProcedure. It takes
    > one parametr @OrderId
    >
    > This dataset is source of C1DataViewSet. Of course I can't use AutoFetch
    > because C1DataViewSet is unable to fill data without parameter @OrderId :-(
    >
    > Well, in Form.Load event I fill BaseTable manually:
    > Dim ta As New NorthwindDataSetTableAdapters.CustOrdersDetailTableAdapter
    > ta.Fill(NorthwindDataSet.CustOrdersDetail, 10260)
    >
    > And now
    > C1DataViewSet1.Views(0).BaseTables(0).Rows.Count returns 4 BUT
    > C1DataViewSet1.Views(0).Count is still 0.
    >
    > I think, that in earlier versions of C1DataViewSet this works fine.
    > (Now I use C1DataExtender.2_2.0.20063.38)
     
    Internally C1DataView operates in two modes - database mode and in-memory mode. These modes are being selected automatically - if all the base DataTables of the view has TableAdapters then view operates in the database mode, which means that view performs a data fetching from a server and doesn't show the rowset until the fetch will be performed.
    If one of the base tables has no a TableAdapter then view can't fetch a data from server and just exposes a rowset based on what the base table rowsets contain - this case is referred to as in-memory mode, and this is what you need.
    Unfortunately C1DataView has no a public property that allows manually select a necessary mode - I hope we'll add it in the nearest future.
    The only workaround I see for now is the following. You may create a table (say CustOrdersDetailInMemory) in the DataSet with the same structure as CustOrdersDetail, but without a TableAdapter, and define C1DataView so as to represent the CustOrdersDetailInMemory. In run-time you fill the CustOrdersDetail and copy its rows to CustOrdersDetailInMemory:
    foreach (DataRow row in CustOrdersDetail)
       CustOrdersDetailInMemory.Rows.Add(row.ItemArray);
    You can't fill the CustOrdersDetailInMemory table directly because of the CustOrdersDetailTableAdapter.Fill() method has typed parameters. But in the same time the CustOrdersDetailTableAdapter class has the private Adapter property, which returns a non-typed DbAdapter (see its definition in the NorthwindDataSet.Designer.vb file). Because the CustOrdersDetailTableAdapter class is defined as "partial", you may add the public property (say PublicAdapter) in the custom part of NorthwindDataSet (NorthwindDataSet.vb file) which just returns a value of the private Adapter property, and use the PublicAdapter.Fill() method to fill the CustOrdersDetailInMemory directly - this should work because Adapter is non-typed and the structures of the tables are the same.
     
    Thanks,
    Alex

    >
    > How to manage this situation correctly?
    >
    > Thanks
    >
    > ViktorS
    >
    > (Of course, that I need more complex StoredProcedure with parameters)
    >
    > --------------------------------------------------------------------------------
    > http://home.componentone.com/cs/forums/187699/ShowPost.aspx
    >
    >


    http://home.componentone.com/cs/forums/187699/ShowPost.aspx#187715

  • 11-05-2007 11:28 AM In reply to

    Re: How to fill data with parameters

    This works fine for loading data, but how would you update your changes?

    Bogdan

  • 11-08-2007 1:48 PM In reply to

    Re: How to fill data with parameters

    I have tested Alex approach using "in-memory" table but failed in one aspect.Using Add() method to copy data to CustOrdersDetailInMemory that is bound to C1TrueDBGrid control is unbearably slow.-----  foreach (DataRow row in CustOrdersDetail)   CustOrdersDetailInMemory.Rows.Add(row.ItemArray);----In my test this for loop was ~150 times slower than CustOrdersDetail.Fill() If you have to load 100,0000 rows you might as well take a day-off 

    This problem is extremely important since there C1DataViewSet is totally useless when needs to be updated and is bound to C1TrueDBGrid and has over 5,000 rows of data.

    Update() of a single modified row in a view with 6000 rows and bound to TrueDBGrid takes ~10 minutes.  

    Are those components really that bad?

     

    Bogdan J.

Page 1 of 1 (5 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.