Multiple Database Tables into single DataGrid
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 87
- Joined: Tue Nov 13, 2007 6:40 pm
Multiple Database Tables into single DataGrid
I have a database with multiple tables that are very similar that I would like to display into a single DataGrid Table.
I SELECT the values from the database and create a multi-dimensional array that easily goes into the DataGrid.
I've been looking for a way to define a column in the DataGrid and had multiple DB columns in the same column.
Data Example
Table ABC
Date
Time
ValueABC
UnitsABC
Table XYZ
Date
Time
ValueXYZ
UnitsXYZ
Can I create a DataGrid with Columns = Date, Time, Value and Units and then configure a way to display ValueABC in the Value column when TableABC is selected and ValueXYZ in the Value Column when the TableXYZ is selected.
The only way I found was to create a column for both ValueABC and ValueXYZ and then to change the visibility based on what Table is selected.
Anyone have a better option. Thanks in advance for the help.
I SELECT the values from the database and create a multi-dimensional array that easily goes into the DataGrid.
I've been looking for a way to define a column in the DataGrid and had multiple DB columns in the same column.
Data Example
Table ABC
Date
Time
ValueABC
UnitsABC
Table XYZ
Date
Time
ValueXYZ
UnitsXYZ
Can I create a DataGrid with Columns = Date, Time, Value and Units and then configure a way to display ValueABC in the Value column when TableABC is selected and ValueXYZ in the Value Column when the TableXYZ is selected.
The only way I found was to create a column for both ValueABC and ValueXYZ and then to change the visibility based on what Table is selected.
Anyone have a better option. Thanks in advance for the help.
Re: Multiple Database Tables into single DataGrid
Hi dcpbarrington,
I am not sure I understand, but can't you somehow combine (not the Liveocde term!
)
the two arrays with the data of each database call and THEN oput them into a datagrid?
Best
Klaus
I am not sure I understand, but can't you somehow combine (not the Liveocde term!

the two arrays with the data of each database call and THEN oput them into a datagrid?
Best
Klaus
-
- Posts: 87
- Joined: Tue Nov 13, 2007 6:40 pm
Re: Multiple Database Tables into single DataGrid
Klaus,
Thanks you for your response.
Wow. I think I was over complicating the situation, but thinking that I could do it as part of a column group function. Some times you just need someone else to look at the problem.
Convert the Array tags before sending them to the DataGrid so the Array Tags would match the column tags of the DataGrid.
Basically I would need to go through each element of the Array in a REPEAT loop and change the tag names of the array values.
Thank
dcpbarrington
Thanks you for your response.
Wow. I think I was over complicating the situation, but thinking that I could do it as part of a column group function. Some times you just need someone else to look at the problem.
Convert the Array tags before sending them to the DataGrid so the Array Tags would match the column tags of the DataGrid.
Basically I would need to go through each element of the Array in a REPEAT loop and change the tag names of the array values.
Thank
dcpbarrington
Re: Multiple Database Tables into single DataGrid
If the two tables have the same format, a simpler thing might be to use a SQL union command. Then just throw the result into the datagrid.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Multiple Database Tables into single DataGrid
I'm making a deduction from your question that you are referring to is doing a sql "SELECT" to get data? If this is so you can do calls within the "SELECT" command that bring the record set from all the tables into a list.
if you pop across to this link http://forums.runrev.com/viewtopic.php?f=8&t=14672 ,look at the code snippet for this is what I actually do when I need data from more than one table
Regards
Nigel
if you pop across to this link http://forums.runrev.com/viewtopic.php?f=8&t=14672 ,look at the code snippet for this is what I actually do when I need data from more than one table
Regards
Nigel
Re: Multiple Database Tables into single DataGrid
Don't have time to look at it right this sec but.. first you might see if dot notation will work for you during your select.
Something like select tablename1.column,tablename2.column from tablename1,tablename2...
And also look at the "AS" option. select tablename1.date as date1,tablename2.date as date2 from tablename1,tablename2
I haven't tested, and don't know what differences there are between sqlite, mysql, postgresql etc but it might simplify things. Do a single select, teh data comes in as normal, but with headers matching the "as..." names you gave them. So the date from table 1 would have the header date1 and date2 for the date field from table 2.
As I said, haven't tested, and it is untweaked, but seems like it might be a good avenue to look at.
EDIT: Nvm the dot notation, found your other post and you're already doing that. But the select AS still might apply, and you should still be able to use your current join.
Something like select tablename1.column,tablename2.column from tablename1,tablename2...
And also look at the "AS" option. select tablename1.date as date1,tablename2.date as date2 from tablename1,tablename2
I haven't tested, and don't know what differences there are between sqlite, mysql, postgresql etc but it might simplify things. Do a single select, teh data comes in as normal, but with headers matching the "as..." names you gave them. So the date from table 1 would have the header date1 and date2 for the date field from table 2.
As I said, haven't tested, and it is untweaked, but seems like it might be a good avenue to look at.
EDIT: Nvm the dot notation, found your other post and you're already doing that. But the select AS still might apply, and you should still be able to use your current join.