I readily application it switching from filebased datastorage to database based. It features a very great deal of code that's written particularly for the filebased system. To create the switch I'm applying functionality that will act as that old system, the program will be generating optimal utilisation of the database in new code.

One problem would be that the filebased system frequently was reading through single records, and browse them frequently for reviews. This have grown to be a lot of queries towards the database, that is slow.

The concept I've been attempting to flesh out is applying two datasets. One dataset to retrieve a whole table, and the other dataset to question from the first, therefore lowering communication overhead using the database server.

I have attempted to check out the DataSource property of TADODataSet however the dataset still appears to want an association, also it asks the database directly if Connection is designated.

The main reason I would rather obtain the lead to another dataset, instead of moving the first, is the fact that there's already implemented enough logic for emulating that old system. This logic is dependant on getting a dataset that contains just the results as queried using the old interface.

The functionality just support reading through data, not writing it back.

How do i play one dataset to provide values for an additional dataset to choose from?

I'm using Delphi 2007 and MSSQL.

Use a ClientDataSet/DataSetProvider pair to fetch data from a current DataSet. You should use filters around the source dataset, filters around the ClientDataSet and provider occasions to trim the dataset simply to the interesting records.

I have used this method with success over a couple of moving projects and also to mitigate similar situation in which a old SQL Server 7 database was queried 1000's of occasions to retrieve individual records with painful performance costs. Querying it just once after which fetching individual records towards the client dataset was, at that time, not just a stylish solution but an excellent performance boost compared to that application: Probably the most great example was an 8 hour process reduced to fifteen minutes... poor customers loved me that point.

A ClientDataSet is simply a TDataSet you are able to effortlessly integrate into existing code and UI.

You are able to write a function that copies the present row in one TADODataSet to a different.

Here's some code which copies the dwelling in the source dataset before appending data towards the target.

var
    I: Integer;
begin
    dsTarget.Close;
    dsTarget.FieldDefs.Clear;

    for I := 0 to dsSource.FieldDefs.Count - 1 do
        dsTarget.FieldDefs.Add(dsSource.FieldDefs[I].Name,
            dsSource.FieldDefs[I].DataType, dsSource.FieldDefs[I].Size,
            dsSource.FieldDefs[I].Required);

    dsTarget.CreateDataSet;

    dsTarget.Append;
    for I := 0 to dsSource.FieldCount - 1 do
        dsTarget.Fields[I] := dsSource.Fields[I];
    dsTarget.Post;
end;