Discussion:
TBufDataSet, TMemDataSet and a big headache.
Marcelo B de Paula
2010-07-12 23:58:02 UTC
Permalink
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.



--
Marcelo B de Paula
2010-07-13 00:27:32 UTC
Permalink
Please,

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

Thanks.



--
Joost van der Sluis
2010-07-13 11:05:53 UTC
Permalink
Post by 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.
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.
Post by Marcelo B de Paula
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
"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.


--
Marcelo B de Paula
2010-07-13 15:23:05 UTC
Permalink
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 joost at cnoc.nl Tue Jul 13 13:05:53 CEST 2010
Post by 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.
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.
Post by Marcelo B de Paula
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
"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.



--
Joost van der Sluis
2010-07-14 14:36:45 UTC
Permalink
Post by 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.
A perfect example that this information is necessary. Now I wrote a
complete mail with useless information. (My last email that is)
Post by Marcelo B de Paula
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.




--
Michael Van Canneyt
2010-07-14 15:01:45 UTC
Permalink
Post by Joost van der Sluis
Post by 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.
A perfect example that this information is necessary. Now I wrote a
complete mail with useless information. (My last email that is)
Post by Marcelo B de Paula
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.

--
Joost van der Sluis
2010-07-15 10:40:09 UTC
Permalink
Post by Michael Van Canneyt
Post by Joost van der Sluis
Post by 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.
A perfect example that this information is necessary. Now I wrote a
complete mail with useless information. (My last email that is)
Post by Marcelo B de Paula
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.


--
Michael Van Canneyt
2010-07-15 11:11:12 UTC
Permalink
Post by Joost van der Sluis
Post by Michael Van Canneyt
Post by Joost van der Sluis
Post by 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.
A perfect example that this information is necessary. Now I wrote a
complete mail with useless information. (My last email that is)
Post by Marcelo B de Paula
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.

--
Marcelo B de Paula
2010-07-14 22:24:04 UTC
Permalink
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 michael at freepascal.org
Wed Jul 14 17:01:45 CEST 2010
Post by Joost van der Sluis
Post by 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.
A perfect example that this information is necessary. Now I wrote a
complete mail with useless information. (My last email that is)
Post by Marcelo B de Paula
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.



--
Marcelo B de Paula
2010-07-15 21:35:01 UTC
Permalink
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.
Marcelo B de Paula
2010-07-16 00:55:48 UTC
Permalink
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.


--
Joost van der Sluis
2010-07-16 08:41:46 UTC
Permalink
Post by 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.
- 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.


--
Marcelo B de Paula
2010-07-16 09:50:39 UTC
Permalink
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 joost at cnoc.nl
Fri Jul 16 10:41:46 CEST 2010
Post by 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.
- 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.



--
Marcelo B de Paula
2010-07-17 01:54:51 UTC
Permalink
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.


--
Maxim Ganetsky
2010-07-17 12:33:16 UTC
Permalink
Post by 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.
Report the bugs, please.
--
Best regards,
Maxim Ganetsky mailto:***@narod.ru

--
Marcelo B de Paula
2010-07-20 00:03:55 UTC
Permalink
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


--

Loading...