 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Arjan Guest
|
Posted: Tue Jan 16, 2007 4:45 pm Post subject: IBDataSet: fields become null |
|
|
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
|
Posted: Tue Jan 16, 2007 10:05 pm Post subject: Re: IBDataSet: fields become null |
|
|
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
|
Posted: Tue Jan 23, 2007 9:11 am Post subject: Re: IBDataSet: fields become null |
|
|
"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
|
Posted: Tue Jan 23, 2007 8:27 pm Post subject: Re: IBDataSet: fields become null |
|
|
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
|
Posted: Wed Jan 24, 2007 6:31 pm Post subject: Re: IBDataSet: fields become null |
|
|
"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
|
Posted: Wed Jan 24, 2007 7:09 pm Post subject: Re: IBDataSet: fields become null |
|
|
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
|
Posted: Fri Jan 26, 2007 9:12 am Post subject: Re: IBDataSet: fields become null |
|
|
"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 |
|
 |
|
|
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
|
|