Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-07

TBufDataSet, TMemDataSet and a big headache.

16 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcelo B de Paula

Hi list,

As the subject of this post suggest, i am in trouble with these components.

I read that TMemDataSet was similar to Delphi?s TClientDataSet as memory dataset. But i also read that people was using TBufDataSet instead of TMemDataSet.

What?s the best option if you want to work with memory datasets?

IMHO, bufdataset looks like an incomplete component. It does not have an option to "create dataset" as memds has. But what confuses me the most is the property editor accessed through context menu (right click component). We already have a property editor assigned to fielddefs and accessed in object inspector.

What exactly is this property editor for? Its option "Add fields" (ctrl+ins) always give me the error "Abstract Method Called", and the other available option "New" (ins), opens the New Field dialog with two possible options: "Calculated" and "Lookup".

But how this is useful if bufdataset do not have an "OnUpdateError" event published? It does not have an OnCalcFields event, so what is this "calculated" field for?

Please, if someone can clarify these doubts, i will appreciate. Or if someone can point me to a document or have a sample source using these components, i will appreciate too.

Thanks in advance.

Reply by email

Marcelo B de Paula

Please,

Where written "bufdataset do not have an "OnUpdateError" event published, should read "TBufDataSet has only the event "OnUpdateError" published."

Thanks.

Reply by email

Joost van der Sluis
to Marcelo B de Paula: As the subject of this post suggest, i am in trouble with these components. I read that…
Marcelo B de Paula wrote 7 lines
Hi list, As the subject of this post suggest, i am in trouble with these components. I read that TMemDataSet was similar to Delphi?s TClientDataSet as memory dataset. But i also read that people was using TBufDataSet instead of TMemDataSet.

TMemDataset is a memory dataset, has nothing to do/in common with TClientDataset, except that it it a dataset that keeps data in memory. (A lot of datasets do that)

TBufDataset looks like the TClientDataset. But do you really need TClientDataset behaviour?

But there are some small bugs in older Lazarus and Fpc versions, which can be fixed with only a few lines of code, but from the rest of your mail I think it is best to advise to upgrade. Use a Lazarus 0.9.29 snapshot with at least fpc 2.4.1.

Show quoted text 16 lines
What?s the best option if you want to work with memory datasets? IMHO, bufdataset looks like an incomplete component. It does not have an option to "create dataset" as memds has. But what confuses me the most is the property editor accessed through context menu (right click component). We already have a property editor assigned to fielddefs and accessed in object inspector. What exactly is this property editor for? Its option "Add fields" (ctrl+ins) always give me the error "Abstract Method Called", and the other available option "New" (ins), opens the New Field dialog with two possible options: "Calculated" and "Lookup". But how this is useful if bufdataset do not have an "OnUpdateError" event published? It does not have an OnCalcFields event, so what is this "calculated" field for?

You can access the OnCalcFields event from code. I think it's published in later versions.

And a general tip: when reporting problems on this ml, always mention your OS, OS version, fpc and lazarus version.

Joost.

Reply by email

Marcelo B de Paula

Thanks Joost for the answer.

I forgot to mention that i am using Lazarus trunk (0.9.29 rev 26602) with fpc 2.5.1.

I just mentioned TClientDataset because of others said here in the list and in Lazarus forum.

My concern is that the component seems to be incomplete e can cause some user headache and needs to be bug reported.

If it is available in component palette, IMHO, it could offer more in design time, and not assume
that the final user will know that he must do all the stuff in code.

BTW, if someone has some sample of its use, please send it to me. Thanks in advance.

Joost van der Sluis Tue Jul 13 13:05:53 CEST 2010

Marcelo B de Paula wrote 8 lines
Hi list, As the subject of this post suggest, i am in trouble with these components. I read that TMemDataSet was similar to Delphi?s TClientDataSet as memory dataset. But i also read that people was using TBufDataSet instead of TMemDataSet.

TMemDataset is a memory dataset, has nothing to do/in common with TClientDataset, except that it it a dataset that keeps data in memory. (A lot of datasets do that)

TBufDataset looks like the TClientDataset. But do you really need TClientDataset behaviour?

But there are some small bugs in older Lazarus and Fpc versions, which can be fixed with only a few lines of code, but from the rest of your mail I think it is best to advise to upgrade. Use a Lazarus 0.9.29 snapshot with at least fpc 2.4.1.

Show quoted text 17 lines
What?s the best option if you want to work with memory datasets? IMHO, bufdataset looks like an incomplete component. It does not have an option to "create dataset" as memds has. But what confuses me the most is the property editor accessed through context menu (right click component). We already have a property editor assigned to fielddefs and accessed in object inspector. What exactly is this property editor for? Its option "Add fields" (ctrl+ins) always give me the error "Abstract Method Called", and the other available option "New" (ins), opens the New Field dialog with two possible options: "Calculated" and "Lookup". But how this is useful if bufdataset do not have an "OnUpdateError" event published? It does not have an OnCalcFields event, so what is this "calculated" field for?

You can access the OnCalcFields event from code. I think it's published in later versions.

And a general tip: when reporting problems on this ml, always mention your OS, OS version, fpc and lazarus version.

Joost.

Reply by email

Joost van der Sluis
to Marcelo B de Paula
Marcelo B de Paula wrote
Thanks Joost for the answer. I forgot to mention that i am using Lazarus trunk (0.9.29 rev 26602) with fpc 2.5.1.

A perfect example that this information is necessary. Now I wrote a complete mail with useless information. (My last email that is)

Show quoted text 12 lines
I just mentioned TClientDataset because of others said here in the list and in Lazarus forum. My concern is that the component seems to be incomplete e can cause some user headache and needs to be bug reported. If it is available in component palette, IMHO, it could offer more in design time, and not assume that the final user will know that he must do all the stuff in code. BTW, if someone has some sample of its use, please send it to me. Thanks in advance.

There are a lot in packages/fcl-db/tests. But maybe not very 'easy' to understand.

I now remember a bur-report that looks like your story. Someone tried to create a dataset using the fields definitions. But that is, afaik, not possible. Also not with a TCLientDataset. (If this is possible using a TClientDataset, please tell me. In that case I have some coding to do)

What you should do us add field-definitions. And then call TBufDataset.CreateTable. Then you can open the dataset and see how the fields got automatically added. Btw: it should be possible to add fields of the data-kind. (Lazarus issue)

If the TMemDs has the ability to create the table from within the IDE, that can be added to TBufDataset too. But that's a Lazarus issue.

I see that there are a lot of properties not published. I'll publish them and ask the 2.4.2 release manager if it is still possible to add this to the final release.

Joost.

Reply by email

Michael Van Canneyt
to Joost van der Sluis
Joost van der Sluis wrote 29 lines
On Tue, 2010-07-13 at 12:23 -0300, Marcelo B de Paula wrote: > Thanks Joost for the answer. > > I forgot to mention that i am using Lazarus trunk (0.9.29 rev 26602) with > fpc 2.5.1. A perfect example that this information is necessary. Now I wrote a complete mail with useless information. (My last email that is) > I just mentioned TClientDataset because of others said here in the list and > in Lazarus forum. > > My concern is that the component seems to be incomplete e can cause some > user headache and needs to be bug reported. > > If it is available in component palette, IMHO, it could offer more in design > time, and not assume > that the final user will know that he must do all the stuff in code. > > BTW, if someone has some sample of its use, please send it to me. > Thanks in advance. There are a lot in packages/fcl-db/tests. But maybe not very 'easy' to understand. I now remember a bur-report that looks like your story. Someone tried to create a dataset using the fields definitions. But that is, afaik, not possible. Also not with a TCLientDataset. (If this is possible using a TClientDataset, please tell me. In that case I have some coding to do)

If you mean fill up FieldDefs, and call 'CreateDataset' : Yes, you can. You can even do it with Persistent fields present.

Michael.

Reply by email

Marcelo B de Paula

Hello Joost and Michael,

Sorry for the late post.

The problem is that fieldsdef and fields don?t get syncronized.

You asked about the TClientDataset behavior. Honestly i use only the fields editor to manage the fields. I add then through fields editor where is possible to define fields types: Data,Calculated,Lookup,Internalcalc and Aggregate. Of course that the last two are specific to ClientDataset. Then I just click in Create DataSet and all is ok. Fieldsdef reflects the same fields i added through fields editor.

I tested the other way, just to see if there was something different. I used fieldsdef editor, than created dataset and than all fields could be added with fields editor.

Bellow, the steps to reproduce:

Through FieldsDef:
- Create new fields through FieldsDef property editor;
- Than call Create Dataset;
- Through Fields property Editor, Added all fields (CTRL+A)
Through Fields Editor:
- Insert new fields of any type supported (Data,Calculated,Lookup);
- Than call Create DataSet;
- All fields are auto inserted in fieldsdef property.

This behaviour do not occur with the components in Lazarus Data Access pallete.

BTW, i created screenshots of the problem within Lazarus. If you want, i can send you.

Other problem i?ve noticed is the limited use of Lazarus NewField form. It is not Delphi compatible, based in what we discussed so far. It does not permit insert fields o type Data, as you noticed in your previous post. This could be a problem to users migrating from Delphi.

And one last note is about the Lazarus behaviour when adding available fields. The dialog that appears to let you select the fields, do not work with multiselect. I tried to select all fields to add at once, and it simply gives an error. If i select one by one, it works.

If you have any question, feel free to ask. I have a demo copy of D7 here, and i can test whatever you want.

Thanks in advance.

Marcelo

Michael Van Canneyt
Wed Jul 14 17:01:45 CEST 2010

Joost van der Sluis wrote 31 lines
On Tue, 2010-07-13 at 12:23 -0300, Marcelo B de Paula wrote: > Thanks Joost for the answer. > > I forgot to mention that i am using Lazarus trunk (0.9.29 rev 26602) with > fpc 2.5.1. A perfect example that this information is necessary. Now I wrote a complete mail with useless information. (My last email that is) > I just mentioned TClientDataset because of others said here in the list > and > in Lazarus forum. > > My concern is that the component seems to be incomplete e can cause some > user headache and needs to be bug reported. > > If it is available in component palette, IMHO, it could offer more in > design > time, and not assume > that the final user will know that he must do all the stuff in code. > > BTW, if someone has some sample of its use, please send it to me. > Thanks in advance. There are a lot in packages/fcl-db/tests. But maybe not very 'easy' to understand. I now remember a bur-report that looks like your story. Someone tried to create a dataset using the fields definitions. But that is, afaik, not possible. Also not with a TCLientDataset. (If this is possible using a TClientDataset, please tell me. In that case I have some coding to do)

If you mean fill up FieldDefs, and call 'CreateDataset' : Yes, you can. You can even do it with Persistent fields present.

Michael.

Reply by email

Joost van der Sluis
to Michael Van Canneyt: If you mean fill up FieldDefs, and call 'CreateDataset' : Yes, you can. You can even do…
Michael Van Canneyt wrote 35 lines
On Wed, 14 Jul 2010, Joost van der Sluis wrote: > On Tue, 2010-07-13 at 12:23 -0300, Marcelo B de Paula wrote: >> Thanks Joost for the answer. >> >> I forgot to mention that i am using Lazarus trunk (0.9.29 rev 26602) with >> fpc 2.5.1. > > A perfect example that this information is necessary. Now I wrote a > complete mail with useless information. (My last email that is) > >> I just mentioned TClientDataset because of others said here in the list and >> in Lazarus forum. >> >> My concern is that the component seems to be incomplete e can cause some >> user headache and needs to be bug reported. >> >> If it is available in component palette, IMHO, it could offer more in design >> time, and not assume >> that the final user will know that he must do all the stuff in code. >> >> BTW, if someone has some sample of its use, please send it to me. >> Thanks in advance. > > There are a lot in packages/fcl-db/tests. But maybe not very 'easy' to > understand. > > I now remember a bur-report that looks like your story. Someone tried to > create a dataset using the fields definitions. But that is, afaik, not > possible. Also not with a TCLientDataset. (If this is possible using a > TClientDataset, please tell me. In that case I have some coding to do) If you mean fill up FieldDefs, and call 'CreateDataset' : Yes, you can. You can even do it with Persistent fields present.

When I wrote 'fields definitions' I meant the definitions of the several TFields in the fields property. Not the FieldDefs.

Sorry for the confusion. It is already possible to use the TFieldDefs to create a dataset. But it is _not_ possible to create a dataset based on TFields. So that's ok?

Joost.

Reply by email

Michael Van Canneyt
to Joost van der Sluis
Joost van der Sluis wrote 43 lines
On Wed, 2010-07-14 at 17:01 +0200, Michael Van Canneyt wrote: > > On Wed, 14 Jul 2010, Joost van der Sluis wrote: > >> On Tue, 2010-07-13 at 12:23 -0300, Marcelo B de Paula wrote: >>> Thanks Joost for the answer. >>> >>> I forgot to mention that i am using Lazarus trunk (0.9.29 rev 26602) with >>> fpc 2.5.1. >> >> A perfect example that this information is necessary. Now I wrote a >> complete mail with useless information. (My last email that is) >> >>> I just mentioned TClientDataset because of others said here in the list and >>> in Lazarus forum. >>> >>> My concern is that the component seems to be incomplete e can cause some >>> user headache and needs to be bug reported. >>> >>> If it is available in component palette, IMHO, it could offer more in design >>> time, and not assume >>> that the final user will know that he must do all the stuff in code. >>> >>> BTW, if someone has some sample of its use, please send it to me. >>> Thanks in advance. >> >> There are a lot in packages/fcl-db/tests. But maybe not very 'easy' to >> understand. >> >> I now remember a bur-report that looks like your story. Someone tried to >> create a dataset using the fields definitions. But that is, afaik, not >> possible. Also not with a TCLientDataset. (If this is possible using a >> TClientDataset, please tell me. In that case I have some coding to do) > > If you mean fill up FieldDefs, and call 'CreateDataset' : Yes, you can. > You can even do it with Persistent fields present. When I wrote 'fields definitions' I meant the definitions of the several TFields in the fields property. Not the FieldDefs. Sorry for the confusion. It is already possible to use the TFieldDefs to create a dataset. But it is _not_ possible to create a dataset based on TFields. So that's ok?

That's OK.

Creating the necessary fielddefs based on TFields would be a no-brainer, though.

Michael.

Reply by email

Marcelo B de Paula

Now i got confused.

Just to clarify, you are telling that the problem to add fields through fields editor is a Lazarus problem? So, NewField form has to be improved?

Will TBufdataset have the option to "create dataset" in design time ?

Thanks.

Marcelo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100715/e1654c72/attachment-0001.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: buf5.PNG
Type: image/png
Size: 50829 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100715/e1654c72/attachment-0001.png>

Reply by email

Marcelo B de Paula

It is late now, but i was looking in newfield.pas to learn how TFields was created.

So, i made the necessary modifications to include the creation of field type Data, that was missing.

Tested and it worked perfectly. Using with TBufDataSet now i can create usable fields.

If you are interested, i submitted the bugreport #16941 with a patch to improve this form.

I am looking forward for the remaining solutions :
- TBufDataSet published events,
- Option to "create dataset" in design time.

Cheers

Marcelo.

Reply by email

Joost van der Sluis
to Marcelo B de Paula
Marcelo B de Paula wrote 15 lines
It is late now, but i was looking in newfield.pas to learn how TFields was created. So, i made the necessary modifications to include the creation of field type Data, that was missing. Tested and it worked perfectly. Using with TBufDataSet now i can create usable fields. If you are interested, i submitted the bugreport #16941 with a patch to improve this form. I am looking forward for the remaining solutions : - TBufDataSet published events, - Option to "create dataset" in design time.

Well, there's nothing that prohibits to create a dataset at design time. The only missing thing is a button which does this. So maybe you could add that too? (Or you could try to find out how to add this to the popup-menu you get when using the second mouse-button)

Then I'll publish the events.

Joost.

Reply by email

Marcelo B de Paula

It seems that i have counted on success too earlier.

Although the behavior of IDE is correct, i am having memory allocation issues when using only the added TFields.
I created a small test program with a BufDataset, Datasource, DBGrid and a Button. Button calls bufdataset Createdataset, Open, Append. Until here all looks good. The fields appear in the grid.
When try to edit, garbage appears in each field, until a SIGSEV is issued.

So, probably TBufDataset are not allocating memory to TFields as it do to TFieldsDef.
How or where to look for this problem.

Thanks in advance.

Marcelo

Joost van der Sluis
Fri Jul 16 10:41:46 CEST 2010

Marcelo B de Paula wrote 16 lines
It is late now, but i was looking in newfield.pas to learn how TFields was created. So, i made the necessary modifications to include the creation of field type Data, that was missing. Tested and it worked perfectly. Using with TBufDataSet now i can create usable fields. If you are interested, i submitted the bugreport #16941 with a patch to improve this form. I am looking forward for the remaining solutions : - TBufDataSet published events, - Option to "create dataset" in design time.

Well, there's nothing that prohibits to create a dataset at design time. The only missing thing is a button which does this. So maybe you could add that too? (Or you could try to find out how to add this to the popup-menu you get when using the second mouse-button)

Then I'll publish the events.

Joost.

Reply by email

Marcelo B de Paula
to Marcelo B de Paula

Hello list,

After trying to figure out how TBufDataSet handles persistent TFields, i came to the following conclusion: There are so many problems and bugs that i can handle.

NewField property editor continue with some implementation problems. The Size field is simply not used anywhere. Which means that when user type some value on it, it does nothing.

Fields Editor editor created successfully the persistent TField in code. Than, while trying to delete these fields, i faced with an AV. Patch sent to Mantis #16958. After this, AVs stopped and persistent fields were removed from code. But not from .lfm, and i don?t know why.

Although fields are created successfully with TBufDataSet "CreateDataSet", they are useless. They don?t retain any information. Seems some memory issue. Integer Fields displays garbage and String Fields simply don?t retain any information. If assigning values to fields in code (FieldByName) i obtain a SIGSEV. Not tested other fields types.

So, sorry guys. It looks like that you need to full review Lazarus related to these components (BufDataSet,MemDataSet,...). I know that people was using these component only in code. But it does not make sense to me, having an IDE, a specific component in palette and can?t use it at design time, only in code.

Now i just want to know if any of the "gurus" here will take some action or i should bugreport all these problems.

Cheers

Marcelo.

Reply by email

Maxim Ganetsky
to Marcelo B de Paula

17.07.2010 5:54, Marcelo B de Paula ?????:

Show quoted text 30 lines
Hello list, After trying to figure out how TBufDataSet handles persistent TFields, i came to the following conclusion: There are so many problems and bugs that i can handle. NewField property editor continue with some implementation problems. The Size field is simply not used anywhere. Which means that when user type some value on it, it does nothing. Fields Editor editor created successfully the persistent TField in code. Than, while trying to delete these fields, i faced with an AV. Patch sent to Mantis #16958. After this, AVs stopped and persistent fields were removed from code. But not from .lfm, and i don?t know why. Although fields are created successfully with TBufDataSet "CreateDataSet", they are useless. They don?t retain any information. Seems some memory issue. Integer Fields displays garbage and String Fields simply don?t retain any information. If assigning values to fields in code (FieldByName) i obtain a SIGSEV. Not tested other fields types. So, sorry guys. It looks like that you need to full review Lazarus related to these components (BufDataSet,MemDataSet,...). I know that people was using these component only in code. But it does not make sense to me, having an IDE, a specific component in palette and can?t use it at design time, only in code. Now i just want to know if any of the "gurus" here will take some action or i should bugreport all these problems.

Report the bugs, please.

Best regards, Maxim Ganetsky mailto:

Reply by email

Marcelo B de Paula

Hello all,

Just to let you know that i?d created bug reports for the problems encountered so far.
Take a look at #16966, #16967, #16968, #16969.

Will be great if someone else could confirm this problems with Lazarus and FPC trunk. Will be great too if someone using FPC 2.4.x could test it too. Not only the TFields problems but the components in general (FieldDefs, CreateDataSet, entering data with DBGrid, ...)

Its very interesting that no one reported such problems. Or they are specific to FPC 2.5.1 with Lazarus 0.9.29 or no one is currently using these components, or they are ok with the stable versions.

Thanks,

Marcelo

Reply by email