Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > DB-Aware

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-12-2009, 05:36 AM
KAM KAM is offline
Senior Member
 
Join Date: Jul 2006
Posts: 216
Default DBGrid & DBTexts

Hi,

I am having trouble with the following:

I have a dbgrid which only shows results from queries and no data can be edited. All of the queries that are shown have a DeviceID field. I would like to use some either labels or dbtext to show data from the main table in these when a user selects a record in grid.

When the query is run and there are no results then the dbtexts show the first record in the table. How can I get around this?

Cheers

Kevin
Reply With Quote
  #2  
Old 08-20-2009, 10:01 AM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Question some more details required

Hi

Can u provide some more details like which database is in the backend and which component library are you using to connect the database table to the datasource of your dbgrid? Also what is the query you are using? Is there is join in that query?
Reply With Quote
  #3  
Old 09-02-2009, 09:29 PM
KevMc KevMc is offline
Member
 
Join Date: Aug 2009
Location: United Kingdom
Posts: 50
Default

Hi,

This was an old post, but there again I still need help on this.

I am using ADO with Microsoft Access as database. I have a main table with a primary key called DeviceID. The Machine Table holds the deviceID field and information about that particular device.

I have an dbgrid that displays the results from different selected queries. Now all of these queries return the DeviceID field.

What I want to do is when I click a record in the dbgrid for it to show information held about that device in some labels/edits below the dbgrid.

Cheers

Kevin
Reply With Quote
  #4  
Old 09-03-2009, 07:14 AM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default

I think it should be simple enough;

Suppose you have two dataset/datasource/DataControl(dbgrid or dblabel). Lets call them Master and child set.

Suppose Master set is related to the table where DeviceID is the primary key and Child set is related to the table/queries which have other details.

Now I understand that you wish that as and when the current/selected/highlighted record change in the master table/dbgrid, the details visible in the child set should show the information related the DeviceID of the current/selected/highlighted record in the master set.

for this there are three ways. simpler one is following:

For Child query/table set the "Master source" property pointing towards the datasource related to master table/dataset and set the "Master Field" property of child table to "DeviceID" . that is all and you have your solution.

Second option is to set filter on child query as DeviceID = ' + quotedStr(MasterTable.fieldvalues['DeviceID'];

Third option is to use bind variable in the query SQL of child query's where clause and supply its value in beforeOpen event of the query from mastertable.fieldvalue......... and then in the AfterScroll event of the master dataset you can close and re-open the child query so it picks related information from the server.

hope it helps
Reply With Quote
  #5  
Old 09-03-2009, 01:54 PM
KevMc KevMc is offline
Member
 
Join Date: Aug 2009
Location: United Kingdom
Posts: 50
Default

Hi,

This has not worked for me. The reason why is that it is more of a child/master detail I want.

I am viewing lots of records with device ID listed. This is a query shown in the grid based on another table which lists lots of ID's and dates and information.

What I want to do is view the information about the device.

Example

MACHINE TABLE - Fields

DeviceID
Manufacturer
MachineType
UpdateDateTime

DATA TABLE - Fields

DEVICEID
LOGDATETIME
INFORMATION1
INFORMATION2
INFORMATION3
INFORMATION4
INFORMATION5

Now I am viewing in my dbgrid a query run on the DATA TABLE. So it shows me deviceID logdatetime and all the INFORMATION (1,2,3,4,5). When I select a row in the grid, I would like labels/texts below the grid to show me Manufacturer and machine type from DEVICE TABLE.

Hope this helps. I know I could add these fields to each query using lookup but I have 35 queries doing different things and I actual want 12 fields from the DEVICE TABLE so this is not the easiest way (or it might have to be).

Really all I want is that when you select a row it gives me the device id, which I can then locate the correct record for texts.

Cheers

Kevin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:32 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.