Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with TClientDataset

Status
Not open for further replies.

lloydie2

Programmer
Apr 21, 2003
75
GB
I am trying to use TclientDataSet so that datasets reside in memeory. I am following an article, but so far I seem to get an error when I set active to 'True'.

The error I get is missing 'Data provider or data packet'

on my form I have:

TclientDataSet
TDatasource (which has the dataset set to the above)

Then I try to put some data in from a sqlite database.

Var
i : integer;
begin
DB := TLiteDB.Create(Self, 'hotelx.sdb3');
DB.Query('Select * from rooms');
For i := 0 to DB.RowCount -1 do
begin
RoomCDS.Open;
RoomCDS.Append;
RoomCDS.FieldByName('room_id').AsInteger := StrToInt(DB.Results[0]);
RoomCDS.FieldByName('room_name').AsString := DB.Results[0];
RoomCDS.Post
end;

any Ideas?
 
Which version of Delphi are you using?

The error message should be a clue.

You need a TDataSetProvider component.

You should set the ProviderName property of your TClientDataset component to the Name of your TDataSetProvider component.

You should set the DataSet property of your TDataSetProvider component to the TDataSet component (in this case your TLiteDB component (assuming it is descended from TDataSet)).

The TDataSetProvider component does all the functionality of the code you wrote in your question for you. That's its purpose.

Andrew
Hampshire, UK
 
I managaged to sort it out by reading from an xml file, although I was hoping to do it in memory.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top