Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi databases: how to not use DBNavigator?

Status
Not open for further replies.

wizzor

Programmer
Aug 29, 2006
23
FI
Hi,
I'm creating a database program, and what I want to do, is display a list of entries on a DBGrid object, and upon double clicking an entry, a new tab would be created on a tabControl object to view detailed information.

The creating of a new page was relatively easy, as was opening the database for editing, but a new problem arose, all the fields display information of the first record in the table.

Of course I could change records by adding a dbnavigator, or by using the same DataSource with the dbgrid, the fields would display same information as the selection of the dbgrid, yet, the reason of having a "complicated" interface like this, is, to allow the handling of multiple information requests at the same time.

The question - briefly - is, what is the value, and in which object that I have to change to select wich _row_ will, say, a dbEdit display.

Oh yeah, this is noobish, but please, have mercy.
 
A couple of ways. You can drop an SQL component and run a query that gets the specific record in the table you are looking for and display that. Or maybe use the FindFirst function on the DataSet. I guess more importantly, how do you know which record to get?

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases:
The Fundamentals of Relational Database Design
Understanding SQL Joi
 
That's another problem, the information is supposed to come from a DBGrid object one way or the other.
 
the detailed information you mentioned, is it another table, than that of the grid, or the same table same record just other fields that are not displayed on the grid ?

Aaron Taylor
John Mutch Electronics
 
They are additional info on the one displayed on the grid (plus, some other info is written on another table, but thats just a new insertion)
Basically additional info though.
 
(I want to display a list of entries on a DBGrid object, and upon double clicking an entry, a new tab would be created on a tabControl object to view detailed information.)

why create the tab at runtime ? just put the dbedits on a tab and set the datasource to that of the grid.

(a problem arose, all the fields display information of the first record in the table.)

this would only happen if the tab table was different than the grid, you will have to syncronise the two.

so there should me no problem if its all 1 table and 1 datasource then the dbedits on the tab should be showing fields from the same record and table as the grid.



Aaron Taylor
John Mutch Electronics
 
The point of the entire program is to be able to view multiple entries at the same time, thus creating the need for runtime page creation.

But I solved the problem. Along with each page, and dbedits, I create a Query object, and export the selected row number (in this case, a target number) with the AsString function.
then, I add an SQL clause to the query, that finds an entry with the same number as in the grid (add 'Select * from database.db where 'TARGNO' = +targno)
targno is a string variable, of course
'The other option would have been to export all the records on the row with AsString, and change the DBEdits with normal edits. Thanks for the help though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top