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 

IBDataSet: fields become null

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





PostPosted: Tue Jan 16, 2007 4:45 pm    Post subject: IBDataSet: fields become null Reply with quote



Hallo,

Recently I upgraded from Delphi 3 to Turbo Delphi.
In an existing project I naively replaced all TQuery components by
TIBDataSet components. No more BDE!

Now if I add a record to a dataset, OnNewRecord sets all fields to
specific initial values. These can then be edited by the user.
However, once the program reaches BeforePost, the fields are null!
Is there something obvious I have overlooked?


Regards,
Arjan
Back to top
Bill Todd
Guest





PostPosted: Tue Jan 16, 2007 10:05 pm    Post subject: Re: IBDataSet: fields become null Reply with quote



Arjan wrote:

Quote:
Now if I add a record to a dataset, OnNewRecord sets all fields to
specific initial values. These can then be edited by the user.
However, once the program reaches BeforePost, the fields are null!
Is there something obvious I have overlooked?

The fields must be set to null by something in your app. Set a
breakpoint in OnNewRecord and step through your code while watching the
value of one of the fields in the Watches window and you should be able
to see when the value changes.

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





PostPosted: Tue Jan 23, 2007 9:11 am    Post subject: Re: IBDataSet: fields become null Reply with quote



"Bill Todd" <no (AT) no (DOT) com> wrote in message
news:45acf7ad$1 (AT) newsgroups (DOT) borland.com...
Quote:
Arjan wrote:

Now if I add a record to a dataset, OnNewRecord sets all fields to
specific initial values. These can then be edited by the user.
However, once the program reaches BeforePost, the fields are null!
Is there something obvious I have overlooked?

The fields must be set to null by something in your app. Set a
breakpoint in OnNewRecord and step through your code while watching
the
value of one of the fields in the Watches window and you should be
able
to see when the value changes.

I set a breakpoint in the OnNewRecord event handler. Lines like
IBDataSet1['name']:='';
IBDataSet1['address']:='';
don't work as I expected: the values of these fields remain null.
That's not the same as an empty string, is it?
If I use
IBDataSet1['name']:=' '; // one space
instead, the fields are null no more.
If this is a FAQ, please kick me in the appropriate direction.


Regards,
Arjan
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Tue Jan 23, 2007 8:27 pm    Post subject: Re: IBDataSet: fields become null Reply with quote

Arjan wrote:

Quote:
I set a breakpoint in the OnNewRecord event handler. Lines like
IBDataSet1['name']:='';
IBDataSet1['address']:='';
don't work as I expected: the values of these fields remain null.

You're going through a variant conversion there. No telling what the
string will end up as. Try a non-variant assignment:

IBDataSet1.FieldByName('name').AsString := '';

I recommend never assigning/reading as variant unless you specifically
want a variant.

-Craig

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Please read and follow Borland's rules for the user of their
server: http://support.borland.com/entry.jspa?externalID=293
Back to top
Arjan
Guest





PostPosted: Wed Jan 24, 2007 6:31 pm    Post subject: Re: IBDataSet: fields become null Reply with quote

"Craig Stuntz [TeamB]" <craig_stuntz (AT) nospam (DOT) please [a.k.a. acm.org]>
wrote in message news:45b61b43 (AT) newsgroups (DOT) borland.com...
Quote:
Arjan wrote:

I set a breakpoint in the OnNewRecord event handler. Lines like
IBDataSet1['name']:='';
IBDataSet1['address']:='';
don't work as I expected: the values of these fields remain null.

You're going through a variant conversion there. No telling what the
string will end up as. Try a non-variant assignment:

IBDataSet1.FieldByName('name').AsString := '';

I recommend never assigning/reading as variant unless you
specifically
want a variant.

-Craig


At the end of the OnNewRecord handler, the field AsString is ''
At the BeforePost event handler, the field value AsString still is ''
(so far, so good).
(BeforePost only has one line, just to set a breakpoint)
When I continue with Shift-F8, I get an EDatabaseError: Field 'NAME'
must have a value.
I'll look for a tutorial on IBDataSets, specifically transactions. Who
knows...


Regards,
Arjan
Back to top
Craig Stuntz [TeamB]
Guest





PostPosted: Wed Jan 24, 2007 7:09 pm    Post subject: Re: IBDataSet: fields become null Reply with quote

Arjan wrote:

Quote:
When I continue with Shift-F8, I get an EDatabaseError: Field 'NAME'
must have a value. I'll look for a tutorial on IBDataSets,
specifically transactions. Who knows...

It's probably missing from your InsertSQL.

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Please read and follow Borland's rules for the user of their
server: http://support.borland.com/entry.jspa?externalID=293
Back to top
Arjan
Guest





PostPosted: Fri Jan 26, 2007 9:12 am    Post subject: Re: IBDataSet: fields become null Reply with quote

"Craig Stuntz [TeamB]" <craig_stuntz (AT) nospam (DOT) please [a.k.a. acm.org]>
wrote in message news:45b75a8b$1 (AT) newsgroups (DOT) borland.com...
Quote:
Arjan wrote:

When I continue with Shift-F8, I get an EDatabaseError: Field
'NAME'
must have a value. I'll look for a tutorial on IBDataSets,
specifically transactions. Who knows...

It's probably missing from your InsertSQL.

Is not!
But perhaps I installed my Turbo Delphi incorrectly. If I click for
Delphi help, I get an OLE error so
it is better to sort out the installation of Delphi first, then worry
about this.

Thanks so far!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (InterBase Express) 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.