BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Object reference

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Martin
Guest





PostPosted: Mon Jan 02, 2006 6:24 am    Post subject: Object reference Reply with quote




Hi,
I have a TSimpleDataSet (D7, kind of a ClientDataSet) and I create an object for each of the records in it. Whilst doing this, I want to store the corresponding object reference in my DataSet.
I tried to add an extra field for this, but that gets messy. I tried the Fields[0].Tag, but this is not a per record property.

Any ideas?

/M
Back to top
Bill Todd
Guest





PostPosted: Mon Jan 02, 2006 12:42 pm    Post subject: Re: Object reference Reply with quote



Martin wrote:

Quote:

Hi,
I have a TSimpleDataSet (D7, kind of a ClientDataSet) and I create an
object for each of the records in it. Whilst doing this, I want to
store the corresponding object reference in my DataSet. I tried to
add an extra field for this, but that gets messy. I tried the
Fields[0].Tag, but this is not a per record property.

Any ideas?

/M

Add a computed field to the SELECT statement that loads the CDS.

SELECT F1, F2, 1000000 AS PTR FROM SOMETABLE

--
Bill Todd (TeamB)

Back to top
Martin
Guest





PostPosted: Mon Jan 02, 2006 1:03 pm    Post subject: Re: Object reference Reply with quote




Hi Bill

As I wrote, I tried just that - but it tends to get messy when
you issue ApplyUpdates since the extra field cant be found.

My present circumvent is to manage a parallell TList with pointers, but this is not at all a preferred solution.

/M

"Bill Todd" <no (AT) no (DOT) com> wrote:
Quote:
Martin wrote:


Hi,
I have a TSimpleDataSet (D7, kind of a ClientDataSet) and I create an
object for each of the records in it. Whilst doing this, I want to
store the corresponding object reference in my DataSet. I tried to
add an extra field for this, but that gets messy. I tried the
Fields[0].Tag, but this is not a per record property.

Any ideas?

/M

Add a computed field to the SELECT statement that loads the CDS.

SELECT F1, F2, 1000000 AS PTR FROM SOMETABLE

--
Bill Todd (TeamB)


Back to top
Bill Todd
Guest





PostPosted: Mon Jan 02, 2006 10:24 pm    Post subject: Re: Object reference Reply with quote

You must set the pfInUpdate ProviderFlag for the field to False. To do
this change the ProviderFlags property of the field object of the
source dataset (the one the DSP is connected to) not the ClientDataSet.
Also read the on-line help for the TField.ProviderFlags property.

--
Bill Todd (TeamB)
Back to top
Martin
Guest





PostPosted: Tue Jan 03, 2006 11:46 am    Post subject: Re: Object reference Reply with quote


ReHi,

Are you sure this works? I connected TSQLDataset->TDatasetProvider->TClientDataset and set the CommandText of the TSQLDataset to 'Select t.*, 0 ObjPtr from MyTable t'

The data shows fine, but the Fields array of the TSQLDataset is empty, and hence no ProviderFlags property can be set.

I can set it for the ObjPtr field on the TClientDataset, but with no effect (as implied by you).

/M


"Bill Todd" <no (AT) no (DOT) com> wrote:
Quote:
You must set the pfInUpdate ProviderFlag for the field to False. To do
this change the ProviderFlags property of the field object of the
source dataset (the one the DSP is connected to) not the ClientDataSet.
Also read the on-line help for the TField.ProviderFlags property.

--
Bill Todd (TeamB)


Back to top
Bill Todd
Guest





PostPosted: Tue Jan 03, 2006 1:06 pm    Post subject: Re: Object reference Reply with quote

Martin wrote:

Quote:
The data shows fine, but the Fields array of the TSQLDataset is
empty, and hence no ProviderFlags property can be set.

Did you instantiate the field objects for the SQLDataSet using the
fields editor? If you do, then you can set the ProviderFlags property
at designe time.

--
Bill Todd (TeamB)

Back to top
Martin
Guest





PostPosted: Tue Jan 03, 2006 1:22 pm    Post subject: Re: Object reference Reply with quote


No I didnt, and I can't. This is a generic routine in an anscester class meant to enumerate objects from nomerous different tables in different descendent classes. Persistent fields are not an option.

/M


"Bill Todd" <no (AT) no (DOT) com> wrote:
Quote:
Martin wrote:

The data shows fine, but the Fields array of the TSQLDataset is
empty, and hence no ProviderFlags property can be set.

Did you instantiate the field objects for the SQLDataSet using the
fields editor? If you do, then you can set the ProviderFlags property
at designe time.

--
Bill Todd (TeamB)


Back to top
Bill Todd
Guest





PostPosted: Tue Jan 03, 2006 2:24 pm    Post subject: Re: Object reference Reply with quote

Martin wrote:

Quote:
No I didnt, and I can't. This is a generic routine in an anscester
class meant to enumerate objects from nomerous different tables in
different descendent classes. Persistent fields are not an option.

Then you will have to set the ProviderFlags property in code.

--
Bill Todd (TeamB)

Back to top
Martin martin_gbg_hotmail
Guest





PostPosted: Wed Jan 04, 2006 10:57 am    Post subject: Re: Object reference Reply with quote


"Bill Todd" <no (AT) no (DOT) com> wrote:
Quote:
Martin wrote:

No I didnt, and I can't. This is a generic routine in an anscester
class meant to enumerate objects from nomerous different tables in
different descendent classes. Persistent fields are not an option.

Then you will have to set the ProviderFlags property in code.

--
Bill Todd (TeamB)


Read earlier posts and you will see that this is what I tried to do - but since the Fields array is empty it is not possible. Field objects are not created in the source dataset, merely in the client dataset.

Well, I guess I will have to settle for a maintaned parallell TList of object pointers, but it is not a preferred solution.

Thanks Bill





Back to top
Bill Todd
Guest





PostPosted: Wed Jan 04, 2006 12:52 pm    Post subject: Re: Object reference Reply with quote

"Martin" martin_gbg_hotmail.com wrote:

Quote:
Read earlier posts and you will see that this is what I tried to do -
but since the Fields array is empty it is not possible. Field objects
are not created in the source dataset, merely in the client dataset.

That is not correct. If you do not instantiate field objects at design
time they are created dynamically at runtime by every descendent of
TDataSet. This has been true since Delphi 1.0. You can set the
ProviderFlags property or any other property of the field objects in
the AfterOpen event handler.

--
Bill Todd (TeamB)

Back to top
Martin
Guest





PostPosted: Wed Jan 04, 2006 1:57 pm    Post subject: Re: Object reference Reply with quote


"Bill Todd" <no (AT) no (DOT) com> wrote:
Quote:
That is not correct. If you do not instantiate field objects at design
time they are created dynamically at runtime by every descendent of
TDataSet. This has been true since Delphi 1.0. You can set the
ProviderFlags property or any other property of the field objects in
the AfterOpen event handler.

Here it is again: I connected TSQLDataset->TDatasetProvider->TClientDataset and set the CommandText of the TSQLDataset to 'Select t.*, 0 ObjPtr from MyTable t'

I then set the Dataset.Active property to true.

TSQLDataset.Fields.Count = 0
TClientDataset.Fields.Count=11

Maybe I am missing something here.

/M


Back to top
Bill Todd
Guest





PostPosted: Wed Jan 04, 2006 7:53 pm    Post subject: Re: Object reference Reply with quote

Sorry. I misunderstood what you said. There is no solution that I know
of in that case. If you do not instantiate the field objects for the
SQLDataSet at design time the DSP has no way to look at the
ProviderFlags when it is generating the SQL statements to apply inserts
and updates.

--
Bill Todd (TeamB)
Back to top
Martin
Guest





PostPosted: Thu Jan 05, 2006 5:57 am    Post subject: Re: Object reference Reply with quote


"Bill Todd" <no (AT) no (DOT) com> wrote:
Quote:
Sorry. I misunderstood what you said. There is no solution that I know
of in that case.

Well, thanks anyway for taking the time, Bill

/M

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.