Inserting with a TDBGrid Problem - Part II

Inserting with a TDBGrid Problem - Part II

Post by Darcy Schult » Wed, 11 Sep 1996 04:00:00

Hi again,

 I posted a message about a week ago and I had several responses that
didn't help me resolve the problem (but thanks for the effort!)  So I
thought that I would post a message that explains the problem a little more

I reproduced the problem in a very simple application.  One window.  A
TDBGrid and TDBNavigator share the client area.  I have a TQuery and a
TDataSource.  The TQuery has the SQL: select country, currency from
country; and is connected to the IBLocal sample Interbase database.  I
select the first row, Click on the '+' button in the navigator, edit the
new row in the first position (typing 'zzz', 'zzz') and then if I click in
another row or on the post button, one of my original rows disappears (not
quite what I described before).  I delete the row I added and then my
original row reappears.  

If I close the query and then reopen it immediately after the post then the
row is there, similarly with closing the application and reopening it.
Could this possibly be a bug?  It seems to me this would be a common
problem.  A grid is a great tool for allowing users to add, modify and
delete rows in a simple table, in a format that they are quite familiar, if
only it displayed the rows correctly.  If you can reproduce it then I'd
like to hear about it and if you have a way to avoid the problem without
having to reselect the entire result set with every post then I would be
extremely happy to hear from you.



Inserting with a TDBGrid Problem - Part II

Post by Thomas M. Schmic » Wed, 11 Sep 1996 04:00:00

Hi Darcy !!

I posted some messages about the same problem
to the newsgroup. Unfortionatly, I got very
little answers. I Made nearly the same test-database
that you described and got the same results.

We tracked down the problem using the VCL-Source to
the point, that the Query is not Refreshable (So your grid
could not be refreshed correctly).

This behavior comes from the fact, that a TQuery has no
property IndexFieldNames, like TTabla has.

Try the following:
Take the same SQL-Statement that you used with your TQuery
and create a View in your database with it.
Now use a TTable instead of a TQuery and connect it to the
View. Before you set the TTAble active, type the Fieldname(s) of
your PrimaryKey into the property IndexFieldNames
Now, you have the same Query-result and everything works fine.
The only problem is, that you can not use Paramters.

To sum it up:
If you try to make a Refresh by Code in your test-Project like
"MyQuery.Refresh", you will get an exception, telling you, that your
Dataset is nor correctly indexed. That is your problem.

Maybe you could forward me, what answers you got (and will get), because
I cannot belive that borland sells a ClientServer-Delphi that doesn't work
with this simple test-project.

Ciao, thomas


1. Newbie cdml q., part ii: update + insert new detail record + print out both

I'm hoping this is a straightforward problem that one of you gurus can help
me overcome! I'm building a series of (3) web forms that, in chronological
order, should enable users:

1. to update an existing profile in a parent db (the form input statement
refers to parent db),

2. add a new record to a detail/many database (input statement refers to
detail db, with token to pass key from parent to detail db), and then

3. print off a web page that brings together the updated profile + the last
entered detail record.

I had problems with form 2 until Paul Ester suggested (in an earlier post)
using tokens to pass the primary key to the detail database (thanks again,
Paul). I'm now (for past 2+ days) stuck on form 3.

Specifically, depending on which db I refer to in my input statement, I can
bring back data for either the last edited record or the updated profile, but
not both, I've tried to set a new (2nd) token (am I allowed to do this?), but
that doesn't work. I've tried to pass a hidden field that refers to
calculated id field from the last edited record, I've tried to pass a hidden
field referring to the foreign key, current record, etc.

I don't mind plugging away at this (its good for learning), but perhaps
someone can point me in the right direction and affirm that what I'm trying
is do-able? E.g., is there a routine way to update a parent database, insert
a new detail record, and then print off a copy of both?


Sent via
Before you buy.

2. SQL Server 7.0 in Multiple Language

3. insert + select part II

4. a pick R83/jbase/universe comparision question

5. Get Identity No. of Newly Inserted Row, Part II (Repost, original doesn't show)

6. US,IL, Chicago: Oracle DBA on RISC 6000

7. Newbie cdml q., part ii: update + insert new detail record + print out both

8. adUseServer record sets (ADO 2.6 & SQL Server 2000)

9. GetChunk problems - part II

10. Complex import/lookup problem (part II)

11. Trigger Problems Part II

12. JDBC Servlet problem under FastTrack (part II)

13. Using Delete and wanting unlogged PART II